internal override bool Process(Token t, HtmlTreeBuilder tb) { if (HtmlTreeBuilderState.IsWhitespace(t)) { // ignore whitespace return true; } else if (t.IsComment()) { tb.Insert(t.AsComment()); } else if (t.IsDoctype()) { // todo: parse error check on expected doctypes // todo: quirk state check on doctype ids Token.Doctype d = t.AsDoctype(); DocumentType doctype = new DocumentType(d.GetName(), d.GetPublicIdentifier(), d.GetSystemIdentifier(), tb.GetBaseUri()); tb.GetDocument().AppendChild(doctype); if (d.IsForceQuirks()) { tb.GetDocument().QuirksMode = DocumentQuirksMode.Quirks; } tb.Transition(HtmlTreeBuilderState.BeforeHtml); } else { // todo: check not iframe srcdoc tb.Transition(HtmlTreeBuilderState.BeforeHtml); return tb.Process(t); // re-process token } return true; }
public void OuterHtmlGeneration() { DocumentType html5 = new DocumentType("html", "", "", ""); Assert.AreEqual("<!DOCTYPE html>", html5.OuterHtml); DocumentType publicDocType = new DocumentType("html", "-//IETF//DTD HTML//", "", ""); Assert.AreEqual("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML//\">", publicDocType.OuterHtml); DocumentType systemDocType = new DocumentType("html", "", "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd", ""); Assert.AreEqual("<!DOCTYPE html \"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd\">", systemDocType.OuterHtml); DocumentType combo = new DocumentType("notHtml", "--public", "--system", ""); Assert.AreEqual("<!DOCTYPE notHtml PUBLIC \"--public\" \"--system\">", combo.OuterHtml); }
internal void Insert(Token.Doctype d) { DocumentType doctypeNode = new DocumentType(d.GetName(), d.GetPublicIdentifier(), d.GetSystemIdentifier(), baseUri); InsertNode(doctypeNode); }
public void ConstructorValidationOkWithBlankPublicAndSystemIds() { DocumentType fail = new DocumentType("html", "", "", ""); }
public void ConstructorValidationThrowsExceptionOnNulls() { DocumentType fail = new DocumentType("html", null, null, ""); }
public void ConstructorValidationOkWithBlankName() { DocumentType fail = new DocumentType("", "", "", ""); }