View Single Post
Old 08-23-2023, 12:50 PM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,439
Karma: 5703082
Join Date: Nov 2009
Device: many
As I tried to explain, how they render on browsers does not make it compliant. The browser parser itself will split that code and inject an ending p tag to prevent the issues when building its internal DOM - just like you can not embed a p tag inside another p tag.

That is what I meant by autofixing.

See the current whatwg parsing code algorithm for details of when closing p tags are injected and why.

See https://html.spec.whatwg.org/multipa...ng-main-inbody

When the next thing to parse is:

Quote:
A start tag whose tag name is one of: "address", "article", "aside", "blockquote", "center", "details", "dialog", "dir", "div", "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "main", "menu", "nav", "ol", "p", "search", "section", "summary", "ul"

If the stack of open elements has a p element in button scope, then close a p element.

Insert an HTML element for the token.
This is the spec followed by current browsers. It effectively terminates the p tag DOM node and then injects the div node.

This makes the code in CodeView be different from the code in Preview (as Preview follows these rules). The gumbo parser we use also follows these rules autofixing the code to match. That is what Mend HTML does.

Last edited by KevinH; 08-23-2023 at 01:02 PM.
KevinH is offline   Reply With Quote