From 9be71a5159d0baf00b59fcad23ff9d55df7aff2e Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 30 Jul 2021 02:08:08 -0400 Subject: [PATCH] Mustache syntax now uses : instead of =. Single words don't need quotes --- shared/naturalcrit/markdown.js | 16 +++++++++------- themes/5ePhb.style.less | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 83828f967..d54adce00 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -31,7 +31,7 @@ const mustacheSpans = { start(src) { return src.match(/{{[^{]/)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const completeSpan = /^{{[^\n]*}}/; // Regex for the complete token - const inlineRegex = /{{(?:="[\w,\-()#%. ]*"|[^"'{}\s])*\s*|}}/g; + const inlineRegex = /{{(?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])*\s*|}}/g; const match = completeSpan.exec(src); if(match) { //Find closing delimiter @@ -77,7 +77,7 @@ const mustacheDivs = { start(src) { return src.match(/\n *{{[^{]/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const completeBlock = /^ *{{[^\s}]*\n.*\n *}}/s; // Regex for the complete token - const blockRegex = /^ *{{(?:="[\w,\-()#%. ]*"|[^"'{}\s])*$|^ *}}$/gm; + const blockRegex = /^ *{{(?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])*$|^ *}}$/gm; const match = completeBlock.exec(src); if(match) { //Find closing delimiter @@ -121,7 +121,7 @@ const mustacheInjectInline = { level : 'inline', start(src) { return src.match(/ *{[^{\n]/)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const inlineRegex = /^ *{((?:="[\w,\-()#%. ]*"|[^"'{}\s])*)}/g; + const inlineRegex = /^ *{((?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])*)}/g; const match = inlineRegex.exec(src); if(match) { const lastToken = tokens[tokens.length - 1]; @@ -156,7 +156,7 @@ const mustacheInjectBlock = { level : 'block', start(src) { return src.match(/\n *{[^{\n]/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const inlineRegex = /^ *{((?:="[\w,\-()#%. ]*"|[^"'{}\s])*)}/ym; + const inlineRegex = /^ *{((?::(?:"[\w,\-()#%. ]*"|[\w\,\-()#%.]*)|[^"'{}\s])*)}/ym; const match = inlineRegex.exec(src); if(match) { const lastToken = tokens[tokens.length - 1]; @@ -313,13 +313,15 @@ const tagRegex = new RegExp(`(${ }).join('|')})`, 'g'); const processStyleTags = (string)=>{ - const tags = string.match(/(?:[^, "=]+|="[^"]*")+/g); + //split tags up. quotes can only occur right after colons. + //TODO: can we simplify to just split on commas? + const tags = string.match(/(?:[^, ":]+|:(?:"[^"]*"|))+/g); if(!tags) return '"'; const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0]; - const classes = _.remove(tags, (tag)=>!tag.includes('"')); - const styles = tags.map((tag)=>tag.replace(/="(.*)"/g, ':$1;')); + const classes = _.remove(tags, (tag)=>!tag.includes(':')); + const styles = tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;')); return `${classes.join(' ')}" ${id ? `id="${id}"` : ''} ${styles.length ? `style="${styles.join(' ')}"` : ''}`; }; diff --git a/themes/5ePhb.style.less b/themes/5ePhb.style.less index a1395554d..ac8fff139 100644 --- a/themes/5ePhb.style.less +++ b/themes/5ePhb.style.less @@ -602,7 +602,7 @@ body { break-inside : avoid; -webkit-transform : translateZ(0); //Prevents shadows from breaking across columns } - .inline { + .inline-block { display : inline-block; text-indent : initial; }