Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show-invisibles plugin throws TypeError exception with Dart and Lisp languages #3789

Open
dregad opened this issue Apr 15, 2024 · 0 comments

Comments

@dregad
Copy link

dregad commented Apr 15, 2024

Information:

  • Prism version: 1.29.0
  • Plugins: show-invisibles
  • Environment: Browser

Description

Exception in the browser's console when displaying a Dart and/or Lisp code block (mantisbt/mantisbt#1986)

[Error] TypeError: undefined is not an object (evaluating 'value.inside')
handleToken (prism-show-invisibles.js:45)
addInvisibles (prism-show-invisibles.js:74)
(anonymous function) (prism-show-invisibles.js:81)
run (prism.min.js:1:5529)
highlightElement (prism.min.js:1:3464)
highlightAllUnder (prism.min.js:1:2775)
highlightAll (prism.min.js:1:2370)
r (prism.min.js:1:6923)

Example

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Prism plugin show-invisibles fails with some languages</title>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css" integrity="sha512-tN7Ec6zAFaVSG3TpNAKtk4DOHNpSwKHxxrsiw4GHKESGPs5njn/0sMCUMl2svV4wo4BK/rCP7juYz+zx+l6oeQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/show-invisibles/prism-show-invisibles.min.css" integrity="sha512-y56hHawsGNNkestAKyhMKxX25fF3QjUkrUESd4qYTPlKqz1s890GRkp95U7vj3tS1Qr/NCYE3bbYOq9MzAXI/A==" crossorigin="anonymous" referrerpolicy="no-referrer" />

	<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js" integrity="sha512-7Z9J3l1+EYfeaPKcGXu3MS/7T+w19WtKQY/n+xzmw4hZhJ9tyYmcUS+4QqAlzhicE5LAfMQSF3iFTK9bQdTxXg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-lisp.min.js" integrity="sha512-W461RnQzrhSCQQMfEGFKOHbK2DuJTVxrXs2PzctPaxV3A+qPB/TcnMgucSsBNkyccNK8VoENBsAnbf/SuBE71g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-dart.min.js" integrity="sha512-r/W8eHXvGAyqo0Pa1hwUx9znj2RKBDKgTZ7iL5R4FIJpLpF1HPXKHiGorzKE5gwj906GlNqAskHKSNpyVziozw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

	<!-- activation breaks lisp and dart.
	<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/show-invisibles/prism-show-invisibles.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	-->
</head>
<body>

<h3>JavaScript</h3>

<pre class="language-javascript"><code>function test() {
	if (true !== false) {
		console.log('foo')
	}
}
</code></pre>

<h3>Dart</h3>

<p>Changing language-dart to language-markup works</p>

<pre><code class="language-dart">
void main() {
	for (int i = 0; i < 10; i++) {
		print('hello ${i + 1}');
	}

	assert(num.parse('42') is int);
	assert(num.parse('0x42') is int);
	assert(num.parse('0.50') is double);
}
</code></pre>

<h3>LISP</h3>

<p>Changing language-lisp to language-markup works</p>

<pre class="language-lisp"><code>
(defun factorial (n)
	(if (= n 0) 1
		(* n (factorial (- n 1)))))
</code></pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant