Closed (duplicate)
Project:
Highlight Js syntax highlighter
Version:
1.1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Oct 2025 at 08:44 UTC
Updated:
19 Nov 2025 at 14:31 UTC
Jump to comment: Most recent
Comments
Comment #2
f0ns commentedComment #3
f0ns commentedComment #4
f0ns commentedComment #6
f0ns commentedComment #7
f0ns commentedComment #8
f0ns commentedComment #9
f0ns commentedYou can see it in action on my live site here:
https://webhaven.io/documentation/theming/theme-structure
Comment #10
sujan shrestha commentedHi Fons, thanks for the suggestion. i see the issue you’re pointing out, and i agree it would be better if the library only fires on code blocks wrapped in pre tags. i will review the JS and make the necessary changes to ensure that inline code doesn’t trigger the library.
Comment #11
f0ns commentedThank you!
It's a minor but important change.
All the best, Fons
Comment #12
f0ns commentedComment #13
f0ns commentedI have it running on 3 websites in production and all is well (it's also a minor change) so I've changed the status to reviewed & tested.
Would love to get this change in so I can get rid of the patches.
Thanks in advance!
Comment #14
norman.lolThe change in the patch only does one thing: it prevents that the "Copy" functionality is getting added to standalone
<code>blocks.The highlighting itself is added via
hljs.highlightAll()which by default runs only onpre code, see https://highlightjs.readthedocs.io/en/latest/api.html.The whole code in the current JS is problematic because it partially gets executed multiple times. First via
once(.., 'code', ..).foreachand inside it via$('code').each(function (i, block) {again.In #3556145: Prevent code to be executed multiple times we got the feedback from this issue included and the duplicate execution fixed, please review over there.
Comment #16
norman.lolComment #17
norman.lolIf possible for you to take a quick look at #3556145: Prevent code to be executed multiple times, your opinion would be much appreciated. If you like the new approach or if you would still prefer a new option to prevent the highlighting and copy functionality kick in on inline code (would be really easy to implement). But maybe the new approach actually fixes the problem already for you..
Chime in when you can 🙂
Comment #18
f0ns commentedJust had a look and looks like a good solution.
Thank you for taking the time to come up with it.
When it’s pushed to a release I’ll update my projects and the SDC components where needed to go with the new flow.
Thank you, if anything would occur I’ll let you know. 🙏
Comment #19
norman.lolYou're welcome! ☺️
Yes, that would be great if you could keep us in the loop when anything looks odd after the update in your project(s).
Comment #20
f0ns commentedJust installed the update and altered my SDC component a little.
Works perfectly now.
You can see the code container and the inline code container in action on this page:
https://webhaven.io/documentation/theming/theme-structure
Thanks!