Closed yfwz100 closed 1 year ago
So... should stream parser be modified to have tags built in?
Or I have to wrap the classHighlighter with the following code:
syntaxHighlighting({
style(tags) {
if (!tags) {
return null;
}
return classHighlighter.style(tags);
},
scope(node) {
return classHighlighter.scope?.(node) ?? false;
}
}),
So... should stream parser be modified to have tags built in?
I don't see why that is necessary. Highlighters are called with an array, not null. I don't see any place where that is not happening.
I created a minimal editor with the above setup.
It's very strange that the facet in the local code is different from the online editor.
The local code in getStyleTags()
reports the root node as:
However, the online one reports:
The props
are different.
I don't know what it's happening...
I finally find the root cause of the above error.
It's because @lezer/common
is being downloaded multiple times in node_modules because of the mismatched versions. The NodeProp's ID is determined by a module-specific global counter. If modules are not shared, the ID is not increased. So the ID is messy.
Tags may be null/undefined when using legacy StreamParser provided in
@codemirror/language
.It will break the highlight code in the following position:
https://github.com/lezer-parser/highlight/blame/5b04ee057d7b0b3d54e8814f31a638c2df707fbe/src/highlight.ts#LL244C10-L244C10