// 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; } }
// 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; } }
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; } }
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; } }
// 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); }
// 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; } }
public override void Read(Tokeniser t, CharacterReader r) { string data = r.ConsumeTo("]]>"); t.Emit(data); r.MatchConsume("]]>"); t.Transition(Data); }
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); } }
public override void Read(Tokeniser t, CharacterReader r) { if (r.Matches('-')) { t.Emit('-'); t.AdvanceTransition(ScriptDataEscapedDashDash); } else { t.Transition(ScriptData); } }
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; } }
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; } }
public override void Read(Tokeniser t, CharacterReader r) { if (r.Matches('/')) { t.CreateTempBuffer(); t.AdvanceTransition(RawtextEndTagOpen); } else { t.Emit('<'); t.Transition(Rawtext); } }
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); } }
// 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); } }
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); } }
private void AnythingElse(Tokeniser t, CharacterReader r) { t.Emit("</" + t.dataBuffer.ToString()); t.Transition(ScriptDataEscaped); }
private void AnythingElse(Tokeniser t, CharacterReader r) { t.Emit("</" + t.dataBuffer.ToString()); t.Transition(Rawtext); }