From d43ea46e408930f176dbe2cf7e0310601fa07c96 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 8 Nov 2023 00:54:43 -0600 Subject: [PATCH] Add subscript and subscript markdown tokens Uses ^^ for superscript and ^^^ subscript as wrappers in the same pattern as italics and bold ( * and **, respectively) Adds editor hot-keys and sytax highlighting. (CTRL-6/CTRL-7) Exact values may not be ideal. Short of the suggestted overloading of ~, I didn't see a better option for the delimiter. --- shared/naturalcrit/markdown.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index d032a37df..62e826e67 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -211,8 +211,8 @@ const superSubScripts = { level : 'inline', start(src) { return src.match(/.*\^\^(.+)\^\^/)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const superRegex = /.*\^\^(.+)\^\^/y; - const subRegex = /.*\^\^\^(.+)\^\^\^/y; + const superRegex = /\^\^(.+)\^\^/y; + const subRegex = /\^\^\^(.+)\^\^\^/y; let isSuper = false; let match = subRegex.exec(src); if(!match){ @@ -220,10 +220,7 @@ const superSubScripts = { if(match) { isSuper = true; } - } else { - console.log(src); } - if(match?.length) { const tags = this.lexer.inlineTokens(match[1]); return {