Example #1
0
 public override bool Process(Token t, TreeBuilder tb)
 {
     if (IsWhitespace(t))
     {
         tb.Insert(t.AsCharacter());
     }
     else if (t.IsComment())
     {
         tb.Insert(t.AsComment());
     }
     else if (t.IsDoctype())
     {
         tb.Error(this);
     }
     else if (t.IsStartTag())
     {
         Token.StartTag startTag = t.AsStartTag();
         string name = startTag.Name();
         if (name.Equals("html"))
         {
             return tb.Process(t, InBody);
         }
         else if (name.Equals("body"))
         {
             tb.Insert(startTag);
             tb.FramesetOk(false);
             tb.Transition(InBody);
         }
         else if (name.Equals("frameset"))
         {
             tb.Insert(startTag);
             tb.Transition(InFrameset);
         }
         else if (StringUtil.In(name, "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "title"))
         {
             tb.Error(this);
             Element head = tb.HeadElement;
             tb.Push(head);
             tb.Process(t, InHead);
             tb.RemoveFromStack(head);
         }
         else if (name.Equals("head"))
         {
             tb.Error(this);
             return false;
         }
         else
         {
             AnythingElse(t, tb);
         }
     }
     else if (t.IsEndTag())
     {
         if (StringUtil.In(t.AsEndTag().Name(), "body", "html"))
         {
             AnythingElse(t, tb);
         }
         else
         {
             tb.Error(this);
             return false;
         }
     }
     else
     {
         AnythingElse(t, tb);
     }
     return true;
 }