0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 18:02:42 +00:00

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.
This commit is contained in:
Trevor Buckner
2024-04-17 01:03:25 -04:00
parent e1186b4a1e
commit 68a68bde82

View File

@@ -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;