public override bool Process(Token t, TreeBuilder tb) { if (IsWhitespace(t)) { tb.Insert(t.AsCharacter()); return true; } switch (t.Type) { case Token.TokenType.Comment: tb.Insert(t.AsComment()); break; case Token.TokenType.Doctype: tb.Error(this); return false; case Token.TokenType.StartTag: Token.StartTag start = t.AsStartTag(); string name = start.Name(); if (name.Equals("html")) { return InBody.Process(t, tb); } else if (StringUtil.In(name, "base", "basefont", "bgsound", "command", "link")) { Element el = tb.InsertEmpty(start); // jsoup special: update base as it is seen. todo: flip to current browser behaviour of one shot if (name.Equals("base") && el.HasAttr("href")) tb.SetBaseUri(el); } else if (name.Equals("meta")) { Element meta = tb.InsertEmpty(start); // todo: charset switches } else if (name.Equals("title")) { HandleRcData(start, tb); } else if (StringUtil.In(name, "noframes", "style")) { HandleRawText(start, tb); } else if (name.Equals("noscript")) { // else if noscript && scripting flag = true: rawtext (jsoup doesn't run script, to handle as noscript) tb.Insert(start); tb.Transition(InHeadNoscript); } else if (name.Equals("script")) { // skips some script rules as won't execute them tb.Insert(start); tb.Tokeniser.Transition(TokeniserState.ScriptData); tb.MarkInsertionMode(); tb.Transition(Text); } else if (name.Equals("head")) { tb.Error(this); return false; } else { return AnythingElse(t, tb); } break; case Token.TokenType.EndTag: Token.EndTag end = t.AsEndTag(); name = end.Name(); if (name.Equals("head")) { tb.Pop(); tb.Transition(AfterHead); } else if (StringUtil.In(name, "body", "html", "br")) { return AnythingElse(t, tb); } else { tb.Error(this); return false; } break; default: return AnythingElse(t, tb); } return true; }