dialect selfClosing is not working - parse error at SelfClosingEndTag #13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
for a semantic stage using this parser
it is useful to know the difference between
">"and"/>"by default, both
">"and"/>"are parsed asEndTagso currently, i need some extra if/then/else logic
i tried to parse
"/>"asSelfClosingEndTagby enabling the
selfClosingdialectbut this gives a parse error at
"/>"input:
<img><br/>lezer-parser-html with default config
">"and"/>"produce node 4lezer-parser-html with
.configure({ dialect: "selfClosing" })"/>"gives a parse errorwhat would
tree-sitter-htmldo?">"and"/>"produce different nodes by default: node 3 and node 6github.com/lezer-parser/html@fa8c9d5810/src/html.grammar (L108-L109)im using a custom tree walker that returns a sequence of tokens
so when i concat all these tokens, i get the original source text
lezer-parser-html
tree-sitter-html
Attached patch should help.
thanks, now
"/>"is parsed asSelfClosingEndTagstupid question: why is the
selfClosingdialect not the default behavior?html can contain arbitrary xml nodes like
<custom/>where i cannot use the node name to detect self-closing nodes
HTML ignores the
/in that syntax and does not treat this as a self-closing tag. So making the parser treat it as if works by default would be confusing to people.aah, because HTML is a subset of SGML
so the DTD defines void elements which can end with
>or/>but actually
/>is XML syntaxrelated: Are (non-void) self-closing tags valid in HTML5?