Closed Nness closed 9 months ago
I tried to use nested language on a custom HTML tag, which the parser throw error when tag is incomplete.
Related code: https://github.com/lezer-parser/html/blob/c95b9713f36ede3e44d380ebade2e3bd25751c4c/src/content.js#L56-L64
mj-style custom tag. I have registered mj-style as one of extra tags, then in nested language we ask lezer/html to use CSS parser if it is mj-style tag.
mj-style
The error is: Invalid inner parse ranges given: [{"from":36,"to":36}]
Invalid inner parse ranges given: [{"from":36,"to":36}]
It happen on following line.
return {parser: tag.parser, overlay: [{from: open.to, to: close.type.id == CloseTag ? close.from : n.to}]}
The way to fix I believe there are two ways.
from === to
After more testing, here are the secnarios.
<mj-style>
<mj-style
<mj-style> code </>
<mj-style>code </mj-st>
Attached patch should help—it makes sure the logic doesn't create an inner parse when there is no content to parse.
Thanks for fast patch 😄
I tried to use nested language on a custom HTML tag, which the parser throw error when tag is incomplete.
Related code: https://github.com/lezer-parser/html/blob/c95b9713f36ede3e44d380ebade2e3bd25751c4c/src/content.js#L56-L64
mj-style custom tag. I have registered
mj-style
as one of extra tags, then in nested language we ask lezer/html to use CSS parser if it ismj-style
tag.The error is:
Invalid inner parse ranges given: [{"from":36,"to":36}]
It happen on following line.
The way to fix I believe there are two ways.
from === to
, then the code should return null.After more testing, here are the secnarios.
<mj-style>
no error<mj-style
error<mj-style> code </>
no error<mj-style>code </mj-st>
no error