tree-sitter / tree-sitter-html

HTML grammar for Tree-sitter
MIT License
136 stars 72 forks source link

`pre` tag inside a `p` tag produces an error #105

Closed stsewd closed 3 months ago

stsewd commented 3 months ago

The following HTML isn't parsed correctly.

<p><pre></pre></p>

It produces the following tree

document [0, 0] - [1, 0]
  element [0, 0] - [0, 3]
    start_tag [0, 0] - [0, 3]
      tag_name [0, 1] - [0, 2]
  element [0, 3] - [0, 14]
    start_tag [0, 3] - [0, 8]
      tag_name [0, 4] - [0, 7]
    end_tag [0, 8] - [0, 14]
      tag_name [0, 10] - [0, 13]
  ERROR [0, 14] - [0, 18]
    ERROR [0, 16] - [0, 17]
ghedwards commented 3 months ago

https://github.com/tree-sitter/tree-sitter-html/blob/master/src/tag.h has pre listed in TAG_TYPES_NOT_ALLOWED_IN_PARAGRAPHS , is this correct ? is it invalid to do this ?

stsewd commented 3 months ago

Oh, that's correct, pre tags can't be inside p tags. I saw a warning in the browser as well.