// in data state, gather characters until a character 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 character (oddly?) t.Emit(r.Consume()); break; case _eof: t.Emit(new Token.EOF()); 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(new Token.EOF()); break; default: string data = r.ConsumeToAny('&', '<', _nullChar); t.Emit(data); break; } }
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) { 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.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); } }
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.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) { if (r.Matches('-')) { t.Emit('-'); t.AdvanceTransition(ScriptDataEscapedDashDash); } else { t.Transition(ScriptData); } }
public override void Read(Tokeniser t, CharacterReader r) { if (r.Matches('/')) { t.CreateTempBuffer(); t.AdvanceTransition(RawTextEndTagOpen); } else { t.Emit('<'); t.Transition(RawText); } }
// 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); } }
// 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) { 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); } }
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; } }
public override void Read(Tokeniser t, CharacterReader r) { if (r.MatchConsume("--")) { t.CreateCommentPending(); t.Transition(CommentStart); } else if (r.MatchConsumeIgnoreCase("DOCTYPE")) { t.Transition(Doctype); } else if (r.MatchConsume("[CDATA[")) { // todo: should actually check current namepspace, and only non-html allows cdata. until namespace // is implemented properly, keep handling as cdata //} else if (!t.currentNodeInHtmlNS() && r.matchConsume("[CDATA[")) { t.Transition(CDataSection); } else { t.Error(this); t.AdvanceTransition(BogusComment); // advance so this character gets in bogus comment data's rewind } }
public override void Read(Tokeniser t, CharacterReader r) { // todo: handle bogus comment starting from eof. when does that trigger? // rewind to capture character that lead us here r.Unconsume(); Token.Comment comment = new Token.Comment(); comment.Data.Append(r.ConsumeTo('>')); // todo: replace nullChar with replaceChar t.Emit(comment); t.AdvanceTransition(Data); }