more html parsing woes

This commit is contained in:
Adam D. Ruppe 2024-09-15 08:38:21 -04:00
parent d246f4d744
commit 156e02bee9
1 changed files with 17 additions and 3 deletions

20
dom.d
View File

@ -1095,6 +1095,17 @@ class Document : FileResource, DomParent {
return n; return n;
} }
/+
// COMMENTED OUT BLOCK
// dom.d used to replace improper close tags with their
// text so they'd be visible in the output. the html
// spec says to just ignore them, and browsers do indeed
// seem to jsut ignore them, even checking back on IE6.
// so i guess i was wrong to do this (tho tbh i find it kinda
// useful to call out an obvious mistake in the source...
// but for calling out obvious mistakes, just use strict
// mode.)
// if not, this is a text node; we can't fix it up... // if not, this is a text node; we can't fix it up...
// If it's already in the tree somewhere, assume it is closed by algorithm // If it's already in the tree somewhere, assume it is closed by algorithm
@ -1115,6 +1126,8 @@ class Document : FileResource, DomParent {
if(!found) // if not found in the tree though, it's probably just text if(!found) // if not found in the tree though, it's probably just text
processNodeWhileParsing(e, TextNode.fromUndecodedString(this, "</"~n.payload~">")); processNodeWhileParsing(e, TextNode.fromUndecodedString(this, "</"~n.payload~">"));
+/
} }
} else { } else {
if(n.element) { if(n.element) {
@ -1778,9 +1791,10 @@ unittest {
bool canNestElementsInHtml(string parentTagName, string childTagName) { bool canNestElementsInHtml(string parentTagName, string childTagName) {
switch(parentTagName) { switch(parentTagName) {
case "p": case "p", "h1", "h2", "h3", "h4", "h5", "h6":
// only should include "phrasing content"
switch(childTagName) { switch(childTagName) {
case "p", "dl", "dt", "dd": case "p", "dl", "dt", "dd", "h1", "h2", "h3", "h4", "h5", "h6":
return false; return false;
default: return true; default: return true;
} }
@ -7819,7 +7833,7 @@ class CssStyle {
setValue(name ~"-left", parts[3], specificity, false); setValue(name ~"-left", parts[3], specificity, false);
break; break;
default: default:
assert(0, value); // assert(0, value);
} }
} }