Maybe it could be useful to introduce a way to pre-process the mininotation string.
For example, something like "<aaa bb cc>" could be pre-processed into "<aaa@3 bb@2 cc@2>" before being transformed into a series of haps by the mini parser.
Or something like "<hello world>" into "<h e l l o ~ w o r l d>"
Or something that computes durations, converting "[a@2 b@5]" into "[a@2 b@5]/7"
In order for the highlighter to work properly, the transformation should keep track of the new symbol's position.
One way to achieve that is prefixing the pattern with a macro function name, example "spelling$<hello world>", and then define somewhere the implementation:
regmacro('spelling', (patternstring) =>
{ /* elaborate and return an object: the new string + the position mapping for each character */ });
I'm really brainstorming without knowing any implications, so take it with a grain of salt...
@felixroos suggests:
might also be possible to have a function that gets passed its location, e.g.
let l = loc('hello'); console.log(l.loc, l.value)
then you could add the location to hap.context manually to get custom highlighting
Maybe it could be useful to introduce a way to pre-process the mininotation string.
For example, something like
"<aaa bb cc>"
could be pre-processed into"<aaa@3 bb@2 cc@2>"
before being transformed into a series of haps by the mini parser.Or something like
"<hello world>"
into"<h e l l o ~ w o r l d>"
Or something that computes durations, converting
"[a@2 b@5]"
into"[a@2 b@5]/7"
In order for the highlighter to work properly, the transformation should keep track of the new symbol's position.
One way to achieve that is prefixing the pattern with a macro function name, example
"spelling$<hello world>"
, and then define somewhere the implementation:I'm really brainstorming without knowing any implications, so take it with a grain of salt...
@felixroos suggests: might also be possible to have a function that gets passed its location, e.g.
then you could add the location to hap.context manually to get custom highlighting