CodeMirror 6: stream-syntax with custom tags

In an attempt to create a Markdown syntax with the new CM6, I’ve been using the stream-syntax module to parse by line. Then I created a custom TagSystem to house tags and types for markdown tokens, as they are quite different from standard programming token types.
The issue I’m having is that the stream-syntax module has hard-coded imports of defaultTags and therefore does not recognize my custom tags I have defined.
I believe this should be parameterized, maybe adding an argument to the StreamSyntax constructor.

That would make sense. However, there’s also a good point to be made for trying to fit your tokens in the default tags, so that they work with regular themes. What kind of tokens do you need that aren’t covered by the default set?

Your point is fair, and in a normal use case, like all editors do, I’d make it work with what token types I already have. I was thinking about including sub-syntaxes and at the same time to style markdown tokens differently.

I’ll use an example to explain: let’s say that I assign all header tokens to keyword. In markdown I’d like to scale the font-size of these tokens based on the header type(ex; H1 -> 32px, H2 -> 24px and so on). The current implementation allows me to do this with the subtype feature, and it’s great. But here comes the problem: suppose I have a code block with some javascript code with keywords in it. The sub-highlighter would give them the keyword type and therefore they’d recieve the font-size values I mentioned above.

I am aware it’s a specific use case and a future markdown implementation would most likely use the default set of token types, but the ability to provide a custom TagSystem to the StreamSyntax would make it much more sane.

That is definitely a good idea too. I’ve opened #275 to track it.