Skip to content

Commit

Permalink
reset regex index when stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Feb 28, 2020
1 parent 72cf351 commit 2a3fe3a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ const HLJS = function(hljs) {
// sometimes they can end up matching nothing at all
// Ref: https://github.com/highlightjs/highlight.js/issues/2140
if (lastMatch.type=="begin" && match.type=="end" && lastMatch.index == match.index && lexeme === "") {
top.terminators.startAt = 0;
// spit the "skipped" character that our regex choked on back into the output sequence
mode_buffer += codeToHighlight.slice(match.index, match.index + 1);
if (!SAFE_MODE) {
Expand Down

0 comments on commit 2a3fe3a

Please sign in to comment.