public override void Read(Tokeniser t, CharacterReader r)
            {
                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    t.Transition(BeforeAttributeName);
                    break;

                case '/':
                    t.Transition(SelfClosingStartTag);
                    break;

                case '>':
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

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

                default:
                    t.Error(this);
                    r.Unconsume();
                    t.Transition(BeforeAttributeName);
                    break;
                }
            }
Exemple #2
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                string value = r.ConsumeToAny('\t', '\n', '\f', ' ', '&', '>', nullChar, '"', '\'', '<', '=', '`');

                if (value.Length > 0)
                {
                    t.tagPending.AppendAttributeValue(value);
                }

                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    t.Transition(BeforeAttributeName);
                    break;

                case '&':
                    string ref2 = t.ConsumeCharacterReference('>', true);
                    if (ref2 == null)
                    {
                        t.tagPending.AppendAttributeValue('&');
                    }
                    else
                    {
                        t.tagPending.AppendAttributeValue(ref2);
                    }
                    break;

                case '>':
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

                case nullChar:
                    t.Error(this);
                    t.tagPending.AppendAttributeValue(replacementChar);
                    break;

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

                case '"':
                case '\'':
                case '<':
                case '=':
                case '`':
                    t.Error(this);
                    t.tagPending.AppendAttributeValue(c);
                    break;

                    // no default, handled in consume to any above
                }
            }
Exemple #3
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    // ignore
                    break;

                case '"':
                    t.Transition(AttributeValue_doubleQuoted);
                    break;

                case '&':
                    r.Unconsume();
                    t.Transition(AttributeValue_unquoted);
                    break;

                case '\'':
                    t.Transition(AttributeValue_singleQuoted);
                    break;

                case nullChar:
                    t.Error(this);
                    t.tagPending.AppendAttributeValue(replacementChar);
                    t.Transition(AttributeValue_unquoted);
                    break;

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

                case '>':
                    t.Error(this);
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

                case '<':
                case '=':
                case '`':
                    t.Error(this);
                    t.tagPending.AppendAttributeValue(c);
                    t.Transition(AttributeValue_unquoted);
                    break;

                default:
                    r.Unconsume();
                    t.Transition(AttributeValue_unquoted);
                    break;
                }
            }
            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;
                }

                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    if (t.IsAppropriateEndTagToken())
                    {
                        t.Transition(BeforeAttributeName);
                    }
                    else
                    {
                        AnythingElse(t, r);
                    }
                    break;

                case '/':
                    if (t.IsAppropriateEndTagToken())
                    {
                        t.Transition(SelfClosingStartTag);
                    }
                    else
                    {
                        AnythingElse(t, r);
                    }
                    break;

                case '>':
                    if (t.IsAppropriateEndTagToken())
                    {
                        t.EmitTagPending();
                        t.Transition(Data);
                    }
                    else
                    {
                        AnythingElse(t, r);
                    }
                    break;

                default:
                    AnythingElse(t, r);
                    break;
                }
            }
            public override void Read(Tokeniser t, CharacterReader r)
            {
                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    // ignore
                    break;

                case '/':
                    t.Transition(SelfClosingStartTag);
                    break;

                case '=':
                    t.Transition(BeforeAttributeValue);
                    break;

                case '>':
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

                case nullChar:
                    t.Error(this);
                    t.tagPending.AppendAttributeName(replacementChar);
                    t.Transition(AttributeName);
                    break;

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

                case '"':
                case '\'':
                case '<':
                    t.Error(this);
                    t.tagPending.NewAttribute();
                    t.tagPending.AppendAttributeName(c);
                    t.Transition(AttributeName);
                    break;

                default:     // A-Z, anything else
                    t.tagPending.NewAttribute();
                    r.Unconsume();
                    t.Transition(AttributeName);
                    break;
                }
            }
Exemple #6
0
            // from before attribute name
            public override void Read(Tokeniser t, CharacterReader r)
            {
                string name = r.ConsumeToAny('\t', '\n', '\f', ' ', '/', '=', '>', nullChar, '"', '\'', '<');

                t.tagPending.AppendAttributeName(name.ToLowerInvariant());

                char c = r.Consume();

                switch (c)
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    t.Transition(AfterAttributeName);
                    break;

                case '/':
                    t.Transition(SelfClosingStartTag);
                    break;

                case '=':
                    t.Transition(BeforeAttributeValue);
                    break;

                case '>':
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

                case nullChar:
                    t.Error(this);
                    t.tagPending.AppendAttributeName(replacementChar);
                    break;

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

                case '"':
                case '\'':
                case '<':
                    t.Error(this);
                    t.tagPending.AppendAttributeName(c);
                    // no default, as covered in consumeToAny
                    break;
                }
            }
Exemple #7
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);
     }
 }
Exemple #8
0
            public override void Read(Tokeniser t, CharacterReader r)
            {
                char c = r.Consume();

                switch (c)
                {
                case '>':
                    t.tagPending.selfClosing = true;
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

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

                default:
                    t.Error(this);
                    t.Transition(BeforeAttributeName);
                    break;
                }
            }
            // from < or </ in data, will have start or end tag pending
            public override void Read(Tokeniser t, CharacterReader r)
            {
                // previous TagOpen state did NOT consume, will have a letter char in current
                string tagName = r.ConsumeToAny('\t', '\n', '\f', ' ', '/', '>', nullChar).ToLowerInvariant();

                t.tagPending.AppendTagName(tagName);

                switch (r.Consume())
                {
                case '\t':
                case '\n':
                case '\f':
                case ' ':
                    t.Transition(BeforeAttributeName);
                    break;

                case '/':
                    t.Transition(SelfClosingStartTag);
                    break;

                case '>':
                    t.EmitTagPending();
                    t.Transition(Data);
                    break;

                case nullChar:     // replacement
                    t.tagPending.AppendTagName(replacementStr);
                    break;

                case eof:     // should emit pending tag?
                    t.EofError(this);
                    t.Transition(Data);
                    // no default, as covered with above consumeToAny
                    break;
                }
            }