-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Plugins incompatibility: File Highlight and Copy to Clipboard #1965
Comments
Alright, after a few hours of debugging your website, I finally found the answer! Yaaaaay TLDR; Don't load the script containing Prism asynchronously until this is fixed. The long version File Highlight and Copy to Clipboard are not incompatible. In fact, the plugin page of Copy to Clipboard uses File Highlight to load the code which is then can then be copied. The problem is that File Highlight has to executed after the initial Then why was File Highlight executed before Depending on how you look at it, the bug is either that File Highlight doesn't use the same async logic as Prism Core or that the async logic of Core doesn't quite work. Thoughts? @mAAdhaTTah @Golmote. Btw. #959 added Prism Core's async logic. |
Interestingly, your website works flawlessly in the best of all browsers: IE11. |
Thanks for spending time on this. I'm sure the devs will nail this one soon. :-) Prism is a great project. I love it. Now for this:
It took me a few minutes to explain this to my wife. :-D |
Your comment on IE 11 yesterday caused me to further test here at work where we use Windows 10 Pro (v. 10.0.17134). Here are the results on browsers on Windows 10: Google Chrome v. 75.0.3770.100 - it works! I also re-tested on Ubuntu 18.04: Google Chrome v. 75.0.3770.100 - "Loading..." on clipboard. What is interesting is we apparently get somewhat different results... Hmmm... |
Interesting results. Another reason for these results is likely to be caching. The cached async script will load almost instantaneously which might fast enough so that everything is loaded before the next frame is rendered which will cause |
To clarify, it's not the "async" logic but the initialization logic, yeah? I ask cuz Prism can run async using a Worker, but I don't think, based on your explanation, that's what happening here. Is that correct? |
With And yes with async logic I mean this initialization logic. |
Yeah... I've never been in love with that logic, even though I wrote some of it1. That said, looking at the file highlight plugin, it does feel like it should hook into Prism, rather than doing its own highlighting and then using Prism. Like control here seems inverted from how it should work. I think we have the hooks to actually make this feasible. We can use Thoughts? Footnotes
|
I really like this idea. A few of my thoughts on this in no particular order.
|
Information:
Does the latest version of Prism from the download page also have this issue? Yes.
Description
The plugin
Copy to Clipboard
works well if the code is sourced between the<pre><code>
tags. On the other hand, if the code was sourced using theFile Highlight
plugin, e.g.<pre data-src="/path/to/asset" class="language-shell" data-download-link="" data-download-link-label="download"></pre>
... then
Copy to Clipboard
fails. Instead of copying the code, it simply copiesLoading…
, which interestingly, is what initially appears whenFile Highlight
is still loading the code from the file.Example
Here is a sample webpage that shows this incompatibility: https://www.majlovesreg.one/adding-brotli-to-a-built-nginx-instance.
The text was updated successfully, but these errors were encountered: