From 68a68bde829f33039c298cc63329d66db0899ece Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 17 Apr 2024 01:03:25 -0400 Subject: [PATCH] Only check for DLs at start of line Previous "start" regex used `^` instead of `\n`, which meant if the first character in a line failed to start a match, it would check for the start of a DL in *every* character in the line, which slows things down a lot. --- shared/naturalcrit/markdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index c2c0710dd..f72955bf3 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -297,7 +297,7 @@ const superSubScripts = { const definitionListsSingleLine = { name : 'definitionListsSingleLine', level : 'block', - start(src) { return src.match(/^[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match + start(src) { return src.match(/\n[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; let match; @@ -329,7 +329,7 @@ const definitionListsSingleLine = { const definitionListsMultiLine = { name : 'definitionListsMultiLine', level : 'block', - start(src) { return src.match(/^[^\n]*\n::/m)?.index; }, // Hint to Marked.js to stop and check for a match + start(src) { return src.match(/\n[^\n]*\n::/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const regex = /(\n?\n?(?!::)[^\n]+?(?=\n::))|\n::(.(?:.|\n)*?(?=(?:\n::)|(?:\n\n)|$))/y; let match;