PrismJS / prism

Lightweight, robust, elegant syntax highlighting.
https://prismjs.com
MIT License
12.33k stars 1.29k forks source link

prism sudennly stopped working #2673

Closed rtwk closed 3 years ago

rtwk commented 3 years ago

I have been using prism on my website for several years. Suddenly I found that it is failing to highlight syntax from today morning. I was using a version 1.15 and I upgraded it wth 1.22; still it is not working. I found one strange thing; when I pasted the js code within script tag, I found that the closing script tag is grey as if there is an error in the script inside. Anybody else facing the same issue? How to fix it?

rtwk commented 3 years ago

So, now the syntax highlighting is coming properly but no line numbering.

edukisto commented 3 years ago

...when I pasted the js code within script tag, I found that the closing script tag is grey as if there is an error in the script inside.

Could you please show us the JS code, the tags, and the error message?

How do you include Prism?

RunDevelopment commented 3 years ago

@rtwk As @edukisto said, we need a way to reproduce your issue or else there nothing we can do.

rtwk commented 3 years ago

I included css code within a style tag. JS file is invoked in a script tag now, instead of including that inline. now the syntax highlighting is coming properly but no line numbering and copy option. There is also a space on the left hand side. Both of the css and js are included at the bottom of the page. That should not be an issue since that is how it was working before this issue occurred. The JS code starts like this : /* PrismJS 1.22.0 https://prismjs.com/download.html#themes=prism-coy&languages= The CSS code :

RunDevelopment commented 3 years ago

@rtwk I'm sorry but this is not enough to reproduce your issue.

Could you please provide a working example of your issue in action? Anything that I can run on my machine is fine (e.g. JSFiddle, or a small example project attached as a .zip file).

rtwk commented 3 years ago

It is seems it is working now. I am attaching a zip file for your reference. Thank you for your support. prism_test.zip

RunDevelopment commented 3 years ago

There is one issue with your file: the spaces between the pre and code tags.

Replacing

<pre class="line-numbers">
<code class="language-python">def find_longest_word(words_list):
    ...
</code>
</pre>

with

<pre class="line-numbers"><code class="language-python">def find_longest_word(words_list):
    ...
</code></pre>

will fix the issue with Coy. Some plugins like Line numbers and Toolbar also have have problems with these spaces, so please make sure to remove them all.

Apart from the spaces, everything seems to be alright. I'm closing this issue now.