Exemplo n.º 1
0
 public void consumeLetterSequence()
 {
     CharacterReader r = new CharacterReader("One &bar; qux");
     Assert.AreEqual("One", r.ConsumeLetterSequence());
     Assert.AreEqual(" &", r.ConsumeTo("bar;"));
     Assert.AreEqual("bar", r.ConsumeLetterSequence());
     Assert.AreEqual("; qux", r.ConsumeToEnd());
 }
Exemplo n.º 2
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                if (r.MatchesLetter())
                {
                    string name = r.ConsumeLetterSequence();
                    t.TagPending.AppendTagName(name.ToLowerInvariant());
                    t.DataBuffer.Append(name);
                    
                    return;
                }

                if (t.IsAppropriateEndTagToken() && !r.IsEmpty())
                {
                    char c = r.Consume();
                    switch (c)
                    {
                        case '\t':
                        case '\n':
                        case '\r':
                        case '\f':
                        case ' ':
                            t.Transition(BeforeAttributeName);
                            break;
                        case '/':
                            t.Transition(SelfClosingStartTag);
                            break;
                        case '>':
                            t.EmitTagPending();
                            t.Transition(Data);
                            break;
                        default:
                            t.DataBuffer.Append(c);
                            AnythingElse(t, r);
                            break;
                    }
                }
                else
                {
                    AnythingElse(t, r);
                }
            }
Exemplo n.º 3
0
            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 '\r':
                    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;
                }
            }
Exemplo n.º 4
0
 public override void Read(Tokeniser t, CharacterReader r)
 {
     if (r.MatchesLetter())
     {
         string name = r.ConsumeLetterSequence();
         t.DoctypePending.Name.Append(name.ToLowerInvariant());
         return;
     }
     char c = r.Consume();
     switch (c)
     {
         case '>':
             t.EmitDoctypePending();
             t.Transition(Data);
             break;
         case '\t':
         case '\n':
         case '\r':
         case '\f':
         case ' ':
             t.Transition(AfterDoctypeName);
             break;
         case _nullChar:
             t.Error(this);
             t.DoctypePending.Name.Append(_replacementChar);
             break;
         case _eof:
             t.EofError(this);
             t.DoctypePending.ForceQuirks = true;
             t.EmitDoctypePending();
             t.Transition(Data);
             break;
         default:
             t.DoctypePending.Name.Append(c);
             break;
     }
 }