コード例 #1
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;
                }
            }
コード例 #2
0
            // 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;
                }
            }
コード例 #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)
            {
                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;
                }
            }
コード例 #5
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                if (r.IsEmpty)
                {
                    t.EofError(this);
                    t.Transition(Data);
                    return;
                }

                char c = r.Consume();

                switch (c)
                {
                case '-':
                    t.Emit(c);
                    t.Transition(ScriptDataEscapedDashDash);
                    break;

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

                case nullChar:
                    t.Error(this);
                    t.Emit(replacementChar);
                    t.Transition(ScriptDataEscaped);
                    break;

                default:
                    t.Emit(c);
                    t.Transition(ScriptDataEscaped);
                    break;
                }
            }
コード例 #6
0
            // from & in data

            public override void Read(Tokeniser t, CharacterReader r)
            {
                string c = t.ConsumeCharacterReference(null, false);

                if (c == null)
                {
                    t.Emit('&');
                }
                else
                {
                    t.Emit(c);
                }

                t.Transition(Data);
            }
コード例 #7
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;
                }
            }
コード例 #8
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                string data = r.ConsumeTo("]]>");

                t.Emit(data);
                r.MatchConsume("]]>");
                t.Transition(Data);
            }
コード例 #9
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                switch (r.Current)
                {
                case nullChar:
                    t.Error(this);
                    r.Advance();
                    t.Emit(replacementChar);
                    break;

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

                default:
                    string data = r.ConsumeTo(nullChar);
                    t.Emit(data);
                    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);
     }
 }
コード例 #11
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.Matches('-'))
     {
         t.Emit('-');
         t.AdvanceTransition(ScriptDataEscapedDashDash);
     }
     else
     {
         t.Transition(ScriptData);
     }
 }
コード例 #12
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                switch (r.Consume())
                {
                case '/':
                    t.CreateTempBuffer();
                    t.Transition(ScriptDataEndTagOpen);
                    break;

                case '!':
                    t.Emit("<!");
                    t.Transition(ScriptDataEscapeStart);
                    break;

                default:
                    t.Emit("<");
                    r.Unconsume();
                    t.Transition(ScriptData);
                    break;
                }
            }
コード例 #13
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.MatchesLetter())
     {
         t.CreateTagPending(false);
         t.Transition(ScriptDataEndTagName);
     }
     else
     {
         t.Emit("</");
         t.Transition(ScriptData);
     }
 }
 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())
                {
                    string name = r.ConsumeLetterSequence();
                    t.dataBuffer.Append(name.ToLowerInvariant());
                    t.Emit(name);
                    return;
                }

                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                case '/':
                case '>':

                    if (t.dataBuffer.ToString().Equals("script"))
                    {
                        t.Transition(ScriptDataEscaped);
                    }
                    else
                    {
                        t.Transition(ScriptDataDoubleEscaped);
                    }

                    t.Emit(c);
                    break;

                default:
                    r.Unconsume();
                    t.Transition(ScriptDataDoubleEscaped);
                    break;
                }
            }
コード例 #16
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.Matches('/'))
     {
         t.CreateTempBuffer();
         t.AdvanceTransition(RawtextEndTagOpen);
     }
     else
     {
         t.Emit('<');
         t.Transition(Rawtext);
     }
 }
コード例 #17
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)
            {
                char c = r.Consume();

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

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

                case '>':
                    t.Emit(c);
                    t.Transition(ScriptData);
                    break;

                case nullChar:
                    t.Error(this);
                    t.Emit(replacementChar);
                    t.Transition(ScriptDataDoubleEscaped);
                    break;

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

                default:
                    t.Emit(c);
                    t.Transition(ScriptDataDoubleEscaped);
                    break;
                }
            }
 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);
     }
 }
コード例 #20
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);
     }
 }
コード例 #21
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);
     }
 }
コード例 #22
0
 private void AnythingElse(Tokeniser t, CharacterReader r)
 {
     t.Emit("</" + t.dataBuffer.ToString());
     t.Transition(ScriptDataEscaped);
 }
コード例 #23
0
 private void AnythingElse(Tokeniser t, CharacterReader r)
 {
     t.Emit("</" + t.dataBuffer.ToString());
     t.Transition(Rawtext);
 }