File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -521,12 +521,18 @@ const HLJS = function(hljs) {
521
521
}
522
522
}
523
523
524
- // edge case for when illegal matches $ (end of line) which is technically
524
+ // edge case for when illegal matches $ (end of line/text ) which is technically
525
525
// a 0 width match but not a begin/end match so it's not caught by the
526
- // first handler (when ignoreIllegals is true)
526
+ // first handler (when ` ignoreIllegals` is true)
527
527
if ( match . type === "illegal" && lexeme === "" ) {
528
- // advance so we aren't stuck in an infinite loop
529
- modeBuffer += "\n" ;
528
+ if ( match . index === codeToHighlight . length ) {
529
+ // we have matched the end of the text, so we can stop without
530
+ // hacking modeBuffer
531
+ } else {
532
+ // matched literal `\n` (with `$`) so we must manually add the newline
533
+ // itself to the modeBuffer so it is not lost when we advance the cursor
534
+ modeBuffer += "\n" ;
535
+ }
530
536
return 1 ;
531
537
}
532
538
You can’t perform that action at this time.
0 commit comments