How to generate the stylesheet for tokens when using both TextMate and Monarch grammars simultaneously
See original GitHub issueI’ve mostly added TextMate grammars support in an app of mine, but that app still uses a Monarch grammar too, and I haven’t been able to figure out how to generate the right CSS for the tokens properly, without having the tokens defined in the Monarch stylesheet override the ones in the TextMate stylesheet and viceversa.
I’m hoping I won’t have to rewrite the Monarch grammar to TextMate as that would have quite a few downsides:
- Most of the times that Monarch grammar will be the only one my users will need, so no need to load Oniguruma at all in that common scenario.
- The Monarch grammar is most probably going to be faster, as it uses JS regexes.
- Also importantly I already have the Monarch grammar at hand, but translating that for TextMate is going to be error prone at best and very time consuming.
I’m guessing the root issue is that I basically have 2 registries for grammars that don’t know about each other, but how could I merge them when the registry for TextMate only seems to handle TextMate grammars?
Any ideas on how to address this issue?
/cc @bolinfest, in case you might have already encountered this issue. Thanks for monaco-tm by the way!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)

Top Related StackOverflow Question
It actually worked!
For posterity, I did the following:
I love Monaco! ❤️
Actually maybe I could just increment the bits the encode the foreground color to achieve this. I’ll have to try this, it sounds promising.
https://github.com/microsoft/vscode/blob/2f077172cb0fcbd06f5820b0a5125215e8d38435/src/vs/editor/common/modes.ts#L172