token: string | null
An optional token style. Multiple styles can be specified by **separating them with dots or spaces**. When the regex for this rule captures groups, it must capture all of the string (since JS provides no way to find out where a group matched), and this property must hold an array of token styles that has one style for each matched group.
The example given is
// You can match multiple tokens at once. Note that the captured
// groups must span the whole string in this case
{regex: /(function)(\s+)([a-z$][\w$]*)/,
token: ["keyword", null, "variable-2"]},
The usage description and example don’t quite match, e.g. the example uses a set [] and commas.
Firstly, I am not sure why you claim that the description does not match the example. It states that the property must hold an array of token styles when using groups, and that is what the example does.
Your first example works fine when I try it. Are you sure there’s a problem with it?
Marijn,
thanks heaps for the quick reply.
All I’m saying is I found the separating them with dots or spaces unclear, does that mean in fact you can say
token: [“style1 style 2”, “style 3”] ?
Thus when editing the page it does not “break” until you scroll down enough for CodeMirror to action the regex on the line containing [[!Category Name]] (which it matches)
At the same time the following and slightly more general
You can add multiple styles to a single token, by passing a string like "link.string" or "link string". When parsing multiple tokens with a single regexp, you have to pass an array containing the styles for the tokens.
What error are you getting when you use the regex and token you pasted?
in Chrome 45.0 with code mirror 5.5 I get the error
Uncaught TypeError: style.replace is not a function
CodeMirror.runMode.callback @ runmode.js:51
CodeMirror.runMode @ runmode.js:66
cmblock @ cmblock.js:8
(anonymous function) @ CodeMirror:826