CM6 StreamParser

Just to add some additional thoughts regarding the new style system (and interop with StreamParser).

(Related: Why does CM6 use the "ͼ" character in class names?)

It seems that custom CM5 modes that rely on tokens <=> css classes will have a lot of trouble adapting to the new system. For example, we have a big stylesheet that applies styles to the various cm- tokens emitted by the CM5 mode. This would have a lot of issues with the new theme/style system, since many of the additional tokens made can’t be easily mapped to already-defined highlight Tag.

I’ve also tried looking for a system guide on how the styling architecture work. In the end, after spending a few hours with the source code, here’s what I think I’ve understood:

  • A language parser generates nodes as NodeType with some kind of names?
  • The highlighter compiles the name and tree down to highlight Tag.
  • The theme chooses what styles to apply for each Tag.
  • style-mod generates anonymous css classes for each Tag, and then associate those with the nodes as they’re generated in DOM.
  • Because the language parser and theme can be written by multiple independent parties, the system is designed to work with a restricted set of Tag, which is also biased towards programming languages.

What would be the intended way, if I want to assign each Node/token to have its css class to be a deterministic value? I’m guessing most likely we’ll need a custom view extension, but I haven’t found any good documentation on the architecture of that.