tree-sitter-html
tree-sitter-html copied to clipboard
support self-closing style/script tags
error cos i did not include the new auto-generated parser files fixed in request #20
From what I can tell, self-closing script and style tags are not allowed in HTML: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
Tag omission None, both the starting and ending tag are mandatory
aah, the html legacy .. self-closing script/style tags are parsed as open-tags https://stackoverflow.com/a/4531813/10440128
so this
<script/>
<script>true</script>
should be parsed as
(fragment
(script_element
(start_tag (tag_name)) ; <script/>
(text) ; \n<script>true
(end_tag (tag_name)) ; </script>
)
)
actual result
(fragment
(ERROR (tag_name)) ; <script/>
(script_element
(start_tag (tag_name)) ; <script>
(raw_text) ; true
(end_tag (tag_name)) ; </script>
)
)
failed attempt to fix
script_start_tag: $ => seq(
'<',
alias($._script_start_tag_name, $.tag_name),
repeat($.attribute),
+ optional('/'), // self-closing tag = open tag (legacy)
'>'
),
i still get (ERROR (tag_name))