PrismJS / prism

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

Syntax highlighting working only on first occasion #1301

Closed rtwk closed 6 years ago

rtwk commented 6 years ago

I am using PrismJS on my website for code blocks. Issue is, on Chrome on Windows 7, Syntax highlighting and line numbering working only on first occasion, so for next code blocks, it is not working. Surprisingly, it is working on Ubuntu + Chrome, Ubuntu + FF, Win 7 + FF. But since a lot of users use Chrome + Win 7, it is very odd looking. Any fix?

Golmote commented 6 years ago

Hi! Can you provide on online example reproducing the issue, so that we can investigate, please?

rtwk commented 6 years ago

For example, in this page - https://www.w3resource.com/python/python-list.php.

mAAdhaTTah commented 6 years ago

This is caused by #1181. You need to update to the latest version.

rtwk commented 6 years ago

Well, I did update to the latest version of Prism. It's PrismJS 1.11.0 (and corresponding css file is also updated). But the issue is yet to be fixed.

Golmote commented 6 years ago

Are you sure you don't have some sort of cache? I just tested the link you gave in Chrome 64 on Windows 7 and could not reproduce this issue. (Unfortunately I did not have the chance to test it before you made the update, so I can't tell for sure the issue was reproduced before that point.)

rtwk commented 6 years ago

Well, write you are. We have Cloudfare Cache. I am in Dev mode now and I see it is working. But, but, line numbering and copy to clipboard are gone. I selected those two options while downloading the js and css code though. My code includes line-numbers class like <pre class="line-numbers"> and it used to come before I updated.

Golmote commented 6 years ago

From the "redownload" URL that appears at the top of your prism.js file, I think you somehow did not include those plugins in your download (or the download page is broken, which would suck). Can you please try downloading it again and double check your selected plugins?

mAAdhaTTah commented 6 years ago

Yeah, I'm not seeing the plugins in the JS served on your site.

rtwk commented 6 years ago

Ok. Let me try it once again.

rtwk commented 6 years ago

Strange problem. I actually select those two plugins. But since I can't see the download js and download css buttons, I have to select, copy and paste both js and css code manually. May be it is missing some code in the process.

mAAdhaTTah commented 6 years ago

The download page produces a URL with everything you selected. Could you share that here?

rtwk commented 6 years ago

Where it is? I found a button for downloading js but no button for css.

mAAdhaTTah commented 6 years ago

In the CSS & JS files on the download page, you see the Prism version and a URL underneath it. That's the one I'm asking for.

Golmote commented 6 years ago

Why can't you see the buttons?

The redownload URL is at the top of both the JS and the CSS files, as you can see partially selected in this screenshot:

https://i.imgur.com/H4AgOzY.png

rtwk commented 6 years ago

Ok. http://prismjs.com/download.html?themes=prism-coy&languages=markup+css+clike+javascript+abap+actionscript+ada+apacheconf+apl+applescript+c+asciidoc+asm6502+aspnet+autohotkey+autoit+bash+basic+batch+bison+brainfuck+bro+cpp+csharp+arduino+coffeescript+ruby+csp+css-extras+d+dart+diff+django+docker+eiffel+elixir+elm+erlang+fsharp+flow+fortran+gherkin+git+glsl+go+graphql+groovy+haml+handlebars+haskell+haxe+http+hpkp+hsts+ichigojam+icon+inform7+ini+io+j+java+jolie+json+julia+keyman+kotlin+latex+less+livescript+lolcode+lua+makefile+markdown+matlab+mel+mizar+monkey+n4js+nasm+nginx+nim+nix+nsis+objectivec+ocaml+opencl+oz+parigp+parser+pascal+perl+php+php-extras+powershell+processing+prolog+properties+protobuf+pug+puppet+pure+python+q+qore+r+jsx+typescript+renpy+reason+rest+rip+roboconf+crystal+rust+sas+sass+scss+scala+scheme+smalltalk+smarty+sql+stylus+swift+tcl+textile+twig+tsx+vbnet+verilog+vhdl+vim+wiki+xeora+xojo+yaml&plugins=line-numbers+toolbar+copy-to-clipboard */

Golmote commented 6 years ago

Alright, this looks good to me. This is the content you need to download. You said you could not see the download buttons, why is that?

rtwk commented 6 years ago

No idea. It comes when I load that url and disappears immediately.

Golmote commented 6 years ago

Is it something that happens on one browser only or on all of them? Did you have the chance to try?

rtwk commented 6 years ago

I tried both FF and Chrome. Both. Same.

Golmote commented 6 years ago

This is really weird... I can't reproduce in any of them. If you manage to find any clue that could help us understand this new issue, please let us know! (Maybe an extension that you would have on both browsers? An antivirus thing maybe?)

Did you manage to copy-paste the code to make your page work properly again?

rtwk commented 6 years ago

Nope. I think when I copy I am missing some code. So Line numbers are not coming.

Golmote commented 6 years ago

Here you go: prism.zip

rtwk commented 6 years ago

Perfect. It worked. Thanks a ton. May I close this issue?

Golmote commented 6 years ago

Glad this is fixed. I'll close the issue. If you happen to understand the cause for the disappearing buttons, please let us know.