Possiblity to highlight whole files using Codemirror in non-markdown files

Use case or problem

I am developing a plugin for editing notes in asciidoc (GitHub - dzruyk/obsidian-asciidoc: Obsidian asciidoc editor plugin) and I can’t highlight asciidoc with public codemirror API because Obisidan uses patched version of Codemirror. Public API of patched version can’t highlight whole files.

Longer version

To highlight asciidoc in edit mode, I tried to use the codemirror API, (in particular the StreamLanguage.define and module GitHub - asciidoctor/codemirror-asciidoc: AsciiDoc mode for CodeMirror). This method of highlighting not works and this is certanly not codemirror-asciidoc issue. I test other highlighters with same result (moreover “pure” Codemirror versions works great with codemirror-asciidoc).

This is because Obsidian change default TreeHighlighter codemirror class. And this default implementation designed to highlight only markdown code blocks.

For markdown files highlighting Obsidian uses private TreeHighlighter implementation which uses internal NodeProp link to get token info from StreamLanguage parser. Since this NodeProp is not available to developer there is no way to highlight files with obsidian/Codemirror public API.

Proposed solution

Developers need public API to highlight whole files with codemirror. Making Obsidian’s internal TreeHighlighter class public may solve the problem, as this would allow for proper codemirror EditorState initialization.

Current workaround (optional)

Now my plugin solves this problem by implementing its own version of TreeHighlighter (in fact, this is a copy of the private version of TreeHighlighter inside Obsidian) and using the hard-coded private identifier ofNodeProp.