Пример #1
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
                }
            }
Пример #2
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);
            }
            public override void Read(Tokeniser t, CharacterReader r)
            {
                string value = r.ConsumeToAny('\'', '&', nullChar);

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

                char c = r.Consume();

                switch (c)
                {
                case '\'':
                    t.Transition(AfterAttributeValue_quoted);
                    break;

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

                    break;

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

                case eof:
                    t.EofError(this);
                    t.Transition(Data);
                    break;
                    // no default, handled in consume to any above
                }
            }