From 7b9a23670d1dcff8d8c54d4fcc862261adf7986f Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 9 Nov 2023 21:31:08 -0600 Subject: [PATCH] Update Regex based on PR siuggestions. This should match more economically and in line with marked recomendations as well as not allow whitespace ( \s ) at the beginning or end of a sub or superscript mark. Additionally, a failure in having mixed sub and supers on the same line was corrected. --- shared/naturalcrit/markdown.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 62e826e67..26bc810e4 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -209,10 +209,10 @@ const mustacheInjectBlock = { const superSubScripts = { name : 'superSubScripts', level : 'inline', - start(src) { return src.match(/.*\^\^(.+)\^\^/)?.index; }, // Hint to Marked.js to stop and check for a match + start(src) { return src.match(/\^\^[^\s].+[^\s]\^\^/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const superRegex = /\^\^(.+)\^\^/y; - const subRegex = /\^\^\^(.+)\^\^\^/y; + const superRegex = /^\^\^([^\s\^][^\^]*[^\s\^])\^\^/m; + const subRegex = /^\^\^\^([^\s\^][^\^]*[^\s\^])\^\^\^/m; let isSuper = false; let match = subRegex.exec(src); if(!match){