Show-invisibles plugin throws TypeError exception with Dart and Lisp languages
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13k
- Forks
- 1.4k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 3
Description
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>
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with plugins/show-invisibles/prism-show-invisibles.js, especially handleToken at line 45 and addInvisibles at line 74, then reproduce the supplied HTML example with Dart and Lisp highlighting. Done means the show-invisibles plugin no longer throws the reported TypeError for either language; add or run a regression check if the repository provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100