mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
perf: skip the emphasis closer scan for inline runs without a delimiter (#4195)
This commit is contained in:
+7
-1
@@ -382,13 +382,19 @@ export class _Lexer<ParserOutput = string, RendererOutput = string> {
|
||||
// The masked source is only read by emStrong and del, which need a *, _ or
|
||||
// ~ to start. Skip building it for a run without one, unless a custom
|
||||
// tokenizer or an emStrongMask hook may read it.
|
||||
const maskedSrc = src.includes('*') || src.includes('_') || src.includes('~')
|
||||
const hasDelimiter = src.includes('*') || src.includes('_') || src.includes('~');
|
||||
const maskedSrc = hasDelimiter
|
||||
|| this.options.hooks?.emStrongMask
|
||||
|| this.tokenizer.emStrong !== _Tokenizer.prototype.emStrong
|
||||
|| this.tokenizer.del !== _Tokenizer.prototype.del
|
||||
? this.#maskSrc(src)
|
||||
: src;
|
||||
|
||||
// Without a delimiter no opener can match, so nothing reads the closer scan.
|
||||
if (!hasDelimiter) {
|
||||
return this.#tokenizeInlines(src, maskedSrc, tokens);
|
||||
}
|
||||
|
||||
// One scan of this maskedSrc for the last emphasis, strong, and
|
||||
// strikethrough closers, shared by every opener in the pass. Popped
|
||||
// when the pass ends so the source is not retained (#4099).
|
||||
|
||||
Reference in New Issue
Block a user