Example #1
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(new Token.EOF());
             break;
         default:
             string data = r.ConsumeToAny('&', '<', _nullChar);
             t.Emit(data);
             break;
     }
 }
Example #2
0
 public void advance()
 {
     CharacterReader r = new CharacterReader("One Two Three");
     Assert.AreEqual('O', r.Consume());
     r.Advance();
     Assert.AreEqual('e', r.Consume());
 }
Example #3
0
 public void AdvanceTransition(TokeniserState state)
 {
     _reader.Advance();
     this._state = state;
 }
Example #4
0
 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;
     }
 }
Example #5
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;
                }
            }
Example #6
0
            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', '\r', '\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);
                }

            }
Example #7
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(new Token.EOF());
             break;
         default:
             string data = r.ConsumeTo(_nullChar);
             t.Emit(data);
             break;
     }
 }
Example #8
0
 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;
     }
 }