diff --git a/index.html b/index.html index aed0e8e..987f63b 100644 --- a/index.html +++ b/index.html @@ -2316,10 +2316,19 @@ consider pick then apply, i.e changeColorLastId() but for next Id */ +let jxrshortcuts = [ /(\d)s (.*)/, /qs ([^\s]+)/, / sa ([^\s]+) (.*)/, /obsv ([^\s]+)/, /observe ([^\s]+)/, /lg ([^\s]+) ([^\s]+)/, /lg ([^\s]+)/] +// could add color per found group function jxrhighlight(){ + // could be run after each note is created instead [...document.querySelectorAll("[value]")] .filter( el => (el.getAttribute("value").match(/^jxr /))) - .map( el => el.setAttribute("troika-text", {colorRanges: {0: 0x0099ff, 3: 0xffffff}}) ) + .map( el => { + let code = el.getAttribute("value") + let foundRanges = {0: 0x0099ff, 3: 0xffffff} + jxrshortcuts.filter( pattern => code.match(pattern) ) + .map( fp => foundRanges[code.search(fp)] = 0xff0000 ) + el.setAttribute("troika-text", {colorRanges: foundRanges}) + }) // see also generalization via https://shiki.matsu.io custom renderers }