You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suspect this is a known limitation and/or expected behaviour, but it was surprising! For context, I'm building a prettier plugin that uses the htmljs-parser directly to format Marko files.
Details
There are two related issues:
Comments within an open tag are not emitted in onComment. They are included in the value of onAttrValue.
When parsing a tag with a comment before the first attribute, the parser does not emit the comment (as far as I can tell).
onComment is never called, and there is no attribute value, so the comment is removed if processed by dependent tooling like the marko compiler (and therefore marko-plugin-prettier).
Using HTML-style comments also throws an error because the parser expects a TypeScript type argument.
I would have expected two values emitted, onAttrValue of "viewport" and onComment with // I'm included in name="viewport"..
The text was updated successfully, but these errors were encountered:
AngusMorton
changed the title
Comments aren't emitted if they are before the first attribute of a tag
Comments aren't emitted if they are in a tag
Dec 27, 2023
Version: 5.5.1
I suspect this is a known limitation and/or expected behaviour, but it was surprising! For context, I'm building a prettier plugin that uses the
htmljs-parser
directly to format Marko files.Details
There are two related issues:
onComment
. They are included in the value ofonAttrValue
.onComment
is never called, and there is no attribute value, so the comment is removed if processed by dependent tooling like the marko compiler (and thereforemarko-plugin-prettier
).Using HTML-style comments also throws an error because the parser expects a TypeScript type argument.
While after the attribute, the value is included in
onAttrValue
of the previous attribute.it parsed as an
onAttrValue
with a value of:I would have expected two values emitted,
onAttrValue
of"viewport"
andonComment
with// I'm included in name="viewport".
.The text was updated successfully, but these errors were encountered: