Description
Workaround
This is a known issue and being discussed (see below). If you run into this the correct solution is to normalize your content to only \n
line breaks BEFORE highlighting.
Describe the issue
Extra line breaks are added to comments if your DOS code uses Windows-style
line endings (CRLF
). The problem is not reproduced if Unix-style line endings
are used (LF
).
I'm not aware of the internal details of highlight.js, but I can assume a
problem with using \s
in the COMMENT
regular expression.
highlight.js/src/languages/dos.js
Line 11 in 4fb68ad
Which language seems to have the issue?
DOS
Are you using highlight
or highlightAuto
?
highlightElement
Sample Code to Reproduce
Run the samples below and see console output.
Windows-style line endings (bad):
https://jsfiddle.net/ua3om8fb/1/
Unix-style line endings (good):
https://jsfiddle.net/8xw4vq39/3/
<span class="hljs-comment">rem line1</span>
<span class="hljs-comment">rem line2</span>
<span class="hljs-comment">rem line1</span>
<span class="hljs-comment">
rem line2</span>