I’m trying to create an instance CodeMirror 6 with the Liquid templating extension. In my use case, I’m going to allow HTML-style comments in the editor, but other HTML is not allowed.
What I’m trying to do is get the editor to apply syntax highlight to the HTML comment blocks, but not have it apply Liquid syntax highlighting inside the comment.
Right now if the editor has something like:
<!--// here is a comment with a liquid {{ name }} variable //-->
The editor will end up applying Liquid syntax highlighting to {{ name }}
.
I’ve been reading through the documentation and searching, but none of the solutions I have tried are working.
How would I get the Liquid extension to ignore parsing HTML comments?
Here’s an example that shows off the issue:
import {basicSetup, EditorView} from "codemirror"
import {liquid} from "@codemirror/lang-liquid";
import {languages} from "@codemirror/language-data"
// The Markdown parser will dynamically load parsers
// for code blocks, using @codemirror/language-data to
// look up the appropriate dynamic import.
let view = new EditorView({
doc: "hello\n<!-- a comment is {{ name }} here -->\nworld",
extensions: [
basicSetup,
liquid()
],
parent: document.body
})
How would I go about updating that example so that the liquid command are ignored in the comments?