Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

<p> text <p> text does not signal a new paragraph, but a nested element #14

Pomax opened this Issue Apr 18, 2012 · 3 comments


None yet
2 participants

Pomax commented Apr 18, 2012

annoying HTML thing, we may or may not want to support this.

Glargh I really despise this feature of HTML.

I can see us needing to support this if we bust up the scraping of sites in the wild and make it possible to edit them using a slowparse-enabled editor, but right now even I avoid the heck out of HTML like that because I have no idea what a browser will make of it. It totally breaks my mental model of how I am supposed to talk to a machine with HTML... But maybe I am a noob that way. :P


Pomax commented May 14, 2012

more complicated than I had hoped due to how we parse HTML so I'm parking this code here for the moment

// The following 13 elements are elements that may or may not have an
// explicit closing tag. Leaving it off is not erroneous. Specified in:
//  http://dev.w3.org/html5/html-author/#index-of-elements
optionallyClosableHtmlElements: ["colgroup", "dd", "dt", "li", "optgroup",
                                 "option", "p", "tbody", "td", "tfoot",
                                 "th", "thead", "tr"],
// This is a helper function to determine whether a given tag
// MUST, or MAY have a closing element. We use this to determine
// whether a missing closing tag is an error or not.
_knownOptionallyClosableHtmlElements: function(tagname) {
  return this.optionallyClosableHtmlElements.indexOf(tagname) > -1;

In order to make this work, we also need to know which elements trigger an auto-close so that we can finalise the DOMBuilder.currentnode


Pomax commented Jun 15, 2012

The exact rules for these elements are described in http://www.w3.org/TR/2010/WD-html5-20100624/syntax.html#optional-tags

@Pomax Pomax closed this Dec 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment