diff --git a/src/highlight.js b/src/highlight.js index b0da8f6159..1486635a34 100644 --- a/src/highlight.js +++ b/src/highlight.js @@ -210,7 +210,7 @@ const HLJS = function(hljs) { } function doIgnore(lexeme) { - if (top.terminators.startAt === 0) { + if (top.matcher.regexIndex === 0) { // no more regexs to potentially match here, so we move the cursor forward one // space mode_buffer += lexeme[0]; @@ -377,16 +377,16 @@ const HLJS = function(hljs) { try { var findNextRegexMatch = false; - top.terminators.startAt = 0; + top.matcher.regexIndex = 0; while (true) { - top.terminators.lastIndex = index; + top.matcher.lastIndex = index; if (findNextRegexMatch) { findNextRegexMatch = false; } else { - top.terminators.startAt = 0; + top.matcher.regexIndex = 0; } - match = top.terminators.exec(codeToHighlight); + match = top.matcher.exec(codeToHighlight); // console.log("match", match[0], match.rule && match.rule.begin) if (!match) break; diff --git a/src/lib/mode_compiler.js b/src/lib/mode_compiler.js index 2916099550..2adff3706d 100644 --- a/src/lib/mode_compiler.js +++ b/src/lib/mode_compiler.js @@ -103,7 +103,7 @@ export function compileLanguage(language) { this.count = 0; this.lastIndex = 0; - this.startAt = 0; + this.regexIndex = 0; } getMatcher(index) { @@ -122,16 +122,16 @@ export function compileLanguage(language) { } exec(s) { - let m = this.getMatcher(this.startAt); + let m = this.getMatcher(this.regexIndex); m.lastIndex = this.lastIndex; let result = m.exec(s); if (result) { - this.startAt += result.position + 1; - if (this.startAt === this.count) // wrap-around - this.startAt = 0; + this.regexIndex += result.position + 1; + if (this.regexIndex === this.count) // wrap-around + this.regexIndex = 0; } - // this.startAt = 0; + // this.regexIndex = 0; return result; } } @@ -242,7 +242,7 @@ export function compileLanguage(language) { compileMode(mode.starts, parent); } - mode.terminators = buildModeRegex(mode); + mode.matcher = buildModeRegex(mode); } // self is not valid at the top-level