Prism4j icon indicating copy to clipboard operation
Prism4j copied to clipboard

Empty string input crashes

Open noties opened this issue 5 years ago • 5 comments

https://github.com/noties/Markwon/issues/192

noties avatar Feb 14 '20 08:02 noties

I'm having this issue with the following markdown file https://raw.githubusercontent.com/yahoo/gifshot/master/README.md

Is there any idea on how to solve this in Prism4j?

Meisolsson avatar Mar 23 '20 19:03 Meisolsson

Hello @Meisolsson !

At first I thought those 2 issues are unreleated. As markdown file that you'd linked does not contain empty code blocks. Then I have found out that the block that fails is:

<script src='gifshot.js'></script>

which does not make sense as it is not empty. If you change script to any other tag, then no crash happens 🤔 . It turns out that javascript grammar injects itself into html grammar to handle this specific case -> javascript code inside <script> tags. But then it is invoked with empty string (as tag does not contain any text)

noties avatar Mar 26 '20 09:03 noties

Alright, any idea how to solve it? I'm guessing that the check causing the crash is required for something else.

Meisolsson avatar Mar 26 '20 14:03 Meisolsson

The fix must be implemented in the library - Prism4j must not tokenize empty inputs

noties avatar Mar 26 '20 15:03 noties

The fix must be implemented in the library - Prism4j must not tokenize empty inputs

Is this fix published or we need to do some dependency workaround to include a fork?

Mine version is 2.0.0, which seems to be the latest, and it's failing for this markdown file:

https://github.com/adambard/learnxinyminutes-docs/blob/master/amd.html.markdown

(disregard the frontmatter since it's not being passed to the markown -> prism4j library).

alexcmgit avatar Feb 12 '23 01:02 alexcmgit