Closed alanruttenberg closed 9 years ago
I see the use, but would like to avoid changing the tokenizer for this as I'd like to deviate as little as possible from the regex and grammar definition of the official standards
I understand the rationale. Any suggestion for doing something that keeps the tokenizer intact but lets the cm class differ?
You could try the following
var checkPlainPrefixes = function(yasqe) {
$(yasqe.getWrapperElement()).find('.cm-string-2').each(function(i, el){
if (val.charAt(val.length-1) == ":") {
$(el).addClass("plainPrefix");
} else {
$(el).removeClass("plainPrefix");
}
})
}
checkPlainPrefixes(yasqe);//run for first time
yasqe.on('change', checkPlainPrefixes);
Then you could use a css rule such as .cm-string-2.plainPrefix {color:black}
The downside of this approach: extra work for every time the cursor changes. Nothing drastic, but still yet another thing to do each time a cursor changes
ps. if jquery is not loaded on your page, you could use the one in the YASQE namespace instead. (i.e. $ -> YASQE.$)
In tokenizer.js push the PNAME_NS higher, but change regex to not allow characters after color. Allows for this styling: