kristoff-it / superhtml

HTML Language Server & Templating Language Library
MIT License
713 stars 24 forks source link

Mark wrong HTML nesting as an error #28

Open kristoff-it opened 1 month ago

kristoff-it commented 1 month ago

The HTML spec defines that some elements cannot be nested in some other elements (eg <div> cannot go under <p>).

The task is to find the complete list, use some judgment to decide if it makes sense for our use case and then add all these cases as errors in the HTML parser code.

bjorn3 commented 1 month ago

Looks like you forgot to escape the html tags, causing them to be hidden in the rendered version of your issue description. Copying the examples from the original lobste.rs comment by someone else: <p><p></p></p> / <p><div></div></p>.

kristoff-it commented 1 month ago

I got markdown'd, thanks!

wong-justin commented 1 month ago

I think the most comprehensive resource will be MDN. They have a "permitted content" entry for each element. For example, see footer, which can have "flow content, but with no <footer> or <header> descendants."

I could do some scraping to generate a complete list if you want.

EDIT - I went ahead and made a list of all the nesting rules