// handles data in title, textarea etc
            public override void Read(Tokeniser t, CharacterReader r)
            {
                switch (r.Current)
                {
                case '&':
                    t.AdvanceTransition(CharacterReferenceInRcdata);
                    break;

                case '<':
                    t.AdvanceTransition(RcdataLessthanSign);
                    break;

                case nullChar:
                    t.Error(this);
                    r.Advance();
                    t.Emit(replacementChar);
                    break;

                case eof:
                    t.Emit(Token.EOF.Instance);
                    break;

                default:
                    string data = r.ConsumeToAny('&', '<', nullChar);
                    t.Emit(data);
                    break;
                }
            }
            public override void Read(Tokeniser t, CharacterReader r)
            {
                char c = r.Current;

                switch (c)
                {
                case '-':
                    t.Emit(c);
                    t.AdvanceTransition(ScriptDataDoubleEscapedDash);
                    break;

                case '<':
                    t.Emit(c);
                    t.AdvanceTransition(ScriptDataDoubleEscapedLessthanSign);
                    break;

                case nullChar:
                    t.Error(this);
                    r.Advance();
                    t.Emit(replacementChar);
                    break;

                case eof:
                    t.EofError(this);
                    t.Transition(Data);
                    break;

                default:
                    string data = r.ConsumeToAny('-', '<', nullChar);
                    t.Emit(data);
                    break;
                }
            }
Esempio n. 3
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                if (r.IsEmpty)
                {
                    t.EofError(this);
                    t.Transition(Data);
                    return;
                }

                switch (r.Current)
                {
                case '-':
                    t.Emit('-');
                    t.AdvanceTransition(ScriptDataEscapedDash);
                    break;

                case '<':
                    t.AdvanceTransition(ScriptDataEscapedLessThanSign);
                    break;

                case nullChar:
                    t.Error(this);
                    r.Advance();
                    t.Emit(replacementChar);
                    break;

                default:
                    string data = r.ConsumeToAny('-', '<', nullChar);
                    t.Emit(data);
                    break;
                }
            }
            public override void Read(Tokeniser t, CharacterReader r)
            {
                if (r.IsEmpty)
                {
                    t.EofError(this);
                    t.doctypePending.forceQuirks = true;
                    t.EmitDoctypePending();
                    t.Transition(Data);
                    return;
                }

                if (r.MatchesAny('\t', '\n', '\f', ' '))
                {
                    r.Advance(); // ignore whitespace
                }
                else if (r.Matches('>'))
                {
                    t.EmitDoctypePending();
                    t.AdvanceTransition(Data);
                }
                else if (r.MatchConsumeIgnoreCase("PUBLIC"))
                {
                    t.Transition(AfterDoctypePublicKeyword);
                }
                else if (r.MatchConsumeIgnoreCase("SYSTEM"))
                {
                    t.Transition(AfterDoctypeSystemKeyword);
                }
                else
                {
                    t.Error(this);
                    t.doctypePending.forceQuirks = true;
                    t.AdvanceTransition(BogusDoctype);
                }
            }
Esempio n. 5
0
            // from < in data
            public override void Read(Tokeniser t, CharacterReader r)
            {
                switch (r.Current)
                {
                case '!':
                    t.AdvanceTransition(MarkupDeclarationOpen);
                    break;

                case '/':
                    t.AdvanceTransition(EndTagOpen);
                    break;

                case '?':
                    t.AdvanceTransition(BogusComment);
                    break;

                default:
                    if (r.MatchesLetter())
                    {
                        t.CreateTagPending(true);
                        t.Transition(TagName);
                    }
                    else
                    {
                        t.Error(this);
                        t.Emit('<');     // char that got us here
                        t.Transition(Data);
                    }
                    break;
                }
            }
Esempio n. 6
0
            // in data state, gather characters until a char reference or tag is found
            public override void Read(Tokeniser t, CharacterReader r)
            {
                switch (r.Current)
                {
                case '&':
                    t.AdvanceTransition(CharacterReferenceInData);
                    break;

                case '<':
                    t.AdvanceTransition(TagOpen);
                    break;

                case nullChar:
                    t.Error(this);     // NOT replacement char (oddly?)
                    t.Emit(r.Consume());
                    break;

                case eof:
                    t.Emit(Token.EOF.Instance);
                    break;

                default:
                    string data = r.ConsumeToAny('&', '<', nullChar);
                    t.Emit(data);
                    break;
                }
            }
            public override void Read(Tokeniser t, CharacterReader r)
            {
                char c = r.Current;

                switch (c)
                {
                case '-':
                    t.AdvanceTransition(CommentEndDash);
                    break;

                case nullChar:
                    t.Error(this);
                    r.Advance();
                    t.commentPending.data.Append(replacementChar);
                    break;

                case eof:
                    t.EofError(this);
                    t.EmitCommentPending();
                    t.Transition(Data);
                    break;

                default:
                    t.commentPending.data.Append(r.ConsumeToAny('-', nullChar));
                    break;
                }
            }
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.MatchesLetter())
     {
         t.CreateTempBuffer();
         t.dataBuffer.Append(char.ToLowerInvariant(r.Current));
         t.Emit("<" + r.Current);
         t.AdvanceTransition(ScriptDataDoubleEscapeStart);
     }
     else if (r.Matches('/'))
     {
         t.CreateTempBuffer();
         t.AdvanceTransition(ScriptDataEscapedEndTagOpen);
     }
     else
     {
         t.Emit('<');
         t.Transition(ScriptDataEscaped);
     }
 }
Esempio n. 9
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.Matches('-'))
     {
         t.Emit('-');
         t.AdvanceTransition(ScriptDataEscapedDashDash);
     }
     else
     {
         t.Transition(ScriptData);
     }
 }
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.Matches('/'))
     {
         t.CreateTempBuffer();
         t.AdvanceTransition(RawtextEndTagOpen);
     }
     else
     {
         t.Emit('<');
         t.Transition(Rawtext);
     }
 }
Esempio n. 11
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                // TODO: handle bogus comment starting from eof. when does that trigger?
                // rewind to capture char that lead us here
                r.Unconsume();
                Token.Comment comment = new Token.Comment();
                comment.data.Append(r.ConsumeTo('>'));
                comment.IsBogus = true;

                // TODO: replace nullChar with replaceChar
                t.Emit(comment);
                t.AdvanceTransition(Data);
            }
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.Matches('/'))
     {
         t.Emit('/');
         t.CreateTempBuffer();
         t.AdvanceTransition(ScriptDataDoubleEscapeEnd);
     }
     else
     {
         t.Transition(ScriptDataDoubleEscaped);
     }
 }
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.MatchesLetter())
     {
         t.CreateTagPending(false);
         t.tagPending.AppendTagName(char.ToLowerInvariant(r.Current));
         t.dataBuffer.Append(r.Current);
         t.AdvanceTransition(ScriptDataEscapedEndTagName);
     }
     else
     {
         t.Emit("</");
         t.Transition(ScriptDataEscaped);
     }
 }
Esempio n. 14
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.IsEmpty)
     {
         t.EofError(this);
         t.Emit("</");
         t.Transition(Data);
     }
     else if (r.MatchesLetter())
     {
         t.CreateTagPending(false);
         t.Transition(TagName);
     }
     else if (r.Matches('>'))
     {
         t.Error(this);
         t.AdvanceTransition(Data);
     }
     else
     {
         t.Error(this);
         t.AdvanceTransition(BogusComment);
     }
 }
Esempio n. 15
0
 // from < in rcdata
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.Matches('/'))
     {
         t.CreateTempBuffer();
         t.AdvanceTransition(RCDATAEndTagOpen);
     }
     else if (r.MatchesLetter() && !r.ContainsIgnoreCase("</" + t.AppropriateEndTagName()))
     {
         // diverge from spec: got a start tag, but there's no appropriate end tag (</title>), so rather than
         // consuming to EOF; break out here
         t.tagPending = new Token.EndTag(t.AppropriateEndTagName());
         t.EmitTagPending();
         r.Unconsume(); // undo "<"
         t.Transition(Data);
     }
     else
     {
         t.Emit("<");
         t.Transition(Rcdata);
     }
 }
Esempio n. 16
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.MatchConsume("--"))
     {
         t.CreateCommentPending();
         t.Transition(CommentStart);
     }
     else if (r.MatchConsumeIgnoreCase("DOCTYPE"))
     {
         t.Transition(Doctype);
     }
     else if (r.MatchConsume("[CDATA["))
     {
         // TODO: should actually check current namepspace, and only non-html allows cdata. until namespace
         // is implemented properly, keep handling as cdata (HtmlCDataSection)
         //} else if (!t.currentNodeInHtmlNS() && r.matchConsume("[CDATA[")) {
         t.Transition(CdataSection);
     }
     else
     {
         t.Error(this);
         t.AdvanceTransition(BogusComment); // advance so this char gets in bogus comment data's rewind
     }
 }