Single line comments in Javascript are not terminated at end of line. Everything after // is formatted as a comment regardless of subsequent line breaks. See the attached image showing the incorrect output.


In the off chance it makes a difference, I'm calling hljs manually: hljs.highlightBlock(codeTag);
I haven't dug super deeply into this yet, but I did play with changing the end pattern. ex. hljs.CLCM.e = "a";, and it still never finds an end for the line comment. I compared against the block comment object CLBM, and can't see any obvious differences that would account for one working but the other not, but can't see anything obvious.
With the screenshots alone, I'm assuming you didn't configure highlight.js to expect <br>s rather than line breaks. You need to call hljs.configure({ useBR: true }) before hljs.highlightBlock(codeTag) and see if that fixes you single line comment issue.
That did it. Apologies for the noise.
Great, thank you!
Most helpful comment
With the screenshots alone, I'm assuming you didn't configure highlight.js to expect
<br>s rather than line breaks. You need to callhljs.configure({ useBR: true })beforehljs.highlightBlock(codeTag)and see if that fixes you single line comment issue.