On Fri, 25 Nov 2022, 18:11 Jean Abou Samra, <j...@abou-samra.fr> wrote:
> What makes you think Pygments can’t do this? You can do > > (?<=\w+)\d+ > Nothing but my not remembering lookaheads/lookbehinds, which I may argue aren't very commom constructs. In fact aside from PERL I'm not even sure what precedent they have (no python doesn't count). Besides, this has nothing to do with pygments, this is the regex matching engine that does its thing, pygments just gratefully receives the benefit. > and things like that. You could also arrange so that the regex parsing a > pitch leaves you in a state of the lexer where something special will > happen for \d+ This does sound like pygments code. Interesting, I wasn't aware you could mess with the state of the lexer to that depth. However, durations don’t always follow a pitch, as in > > \tuplet 3/2 8. { … } > > which is the reason why we don’t want to do that. > Does Lilypond's parser even know that's a duration? Isn't that just a bare string that \tuplet internally interprets as a duration? When implementing this kind of simplistic syntax highlighting (like, ones not assisted by being aware of the semantics of the language, like you'd have in Visual Studio or Qt Creator, say) there's always this problem of how much of the common libraries you reimplement by hand, I'm not sure how Frescobaldi does its thing, for example, a lot of it seems quite magic to me (or the result of a huge labour of love... I mean, that program is just brilliant). Anyways whatever Frescobaldi does, I wonder if we could mimic for Pygments... L