diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 8cafe1ca5..7185cab8e 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -207,34 +207,30 @@ const mustacheInjectBlock = { }; const superSubScripts = { - name : 'superSubScripts', + name : 'superSubScript', level : 'inline', - start(src) { return src.match(/\^\^/m)?.index; }, // Hint to Marked.js to stop and check for a match + start(src) { return src.match(/\^/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const superRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m; - const subRegex = /^\^\^\^([^\s\^][^\^]*[^\s\^])\^\^\^/m; + const superRegex = /^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/m; + const subRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m; let isSuper = false; let match = subRegex.exec(src); if(!match){ match = superRegex.exec(src); - if(match) { + if(match) isSuper = true; - } } if(match?.length) { - const tags = this.lexer.inlineTokens(match[1]); return { - type : 'superSubScripts', // Should match "name" above - raw : match[0], // Text to consume from the source - text : src, - super : isSuper, - tags + type : 'superSubScript', // Should match "name" above + raw : match[0], // Text to consume from the source + tag : isSuper ? 'sup' : 'sub', + tokens : this.lexer.inlineTokens(match[1]) }; } }, renderer(token) { - const tag = token.super ? 'sup' : 'sub'; - return `<${tag}>${this.parser.parseInline(token.tags)}`; + return `<${token.tag}>${this.parser.parseInline(token.tokens)}`; } };