/// <summary> /// Write a token to the output stream. /// </summary> /// <remarks> /// Writes a token that was emitted by the <see cref="HtmlTokenizer"/> /// to the output stream. /// </remarks> /// <param name="token">The HTML token.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="token"/> is <c>null</c>. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteToken(HtmlToken token) { if (token == null) { throw new ArgumentNullException(nameof(token)); } CheckDisposed(); if (WriterState != HtmlWriterState.Default) { WriterState = HtmlWriterState.Default; html.Write(empty ? "/>" : ">"); empty = false; } token.WriteTo(html); }
public bool ReadNextToken(out HtmlToken output) { token = null; while (TokenizerState != HtmlTokenizerState.EndOfFile) { switch (TokenizerState) { case HtmlTokenizerState.Data: ReadDataToken(); break; case HtmlTokenizerState.CharacterReferenceInData: ReadCharacterReferenceInData(); break; case HtmlTokenizerState.RcData: ReadRcData(); break; case HtmlTokenizerState.CharacterReferenceInRcData: ReadCharacterReferenceInRcData(); break; case HtmlTokenizerState.RawText: ReadRawText(); break; case HtmlTokenizerState.ScriptData: ReadScriptData(); break; case HtmlTokenizerState.PlainText: ReadPlainText(); break; case HtmlTokenizerState.TagOpen: ReadTagOpen(); break; case HtmlTokenizerState.EndTagOpen: ReadEndTagOpen(); break; case HtmlTokenizerState.TagName: ReadTagName(); break; case HtmlTokenizerState.RcDataLessThan: ReadRcDataLessThan(); break; case HtmlTokenizerState.RcDataEndTagOpen: ReadRcDataEndTagOpen(); break; case HtmlTokenizerState.RcDataEndTagName: ReadRcDataEndTagName(); break; case HtmlTokenizerState.RawTextLessThan: ReadRawTextLessThan(); break; case HtmlTokenizerState.RawTextEndTagOpen: ReadRawTextEndTagOpen(); break; case HtmlTokenizerState.RawTextEndTagName: ReadRawTextEndTagName(); break; case HtmlTokenizerState.ScriptDataLessThan: ReadScriptDataLessThan(); break; case HtmlTokenizerState.ScriptDataEndTagOpen: ReadScriptDataEndTagOpen(); break; case HtmlTokenizerState.ScriptDataEndTagName: ReadScriptDataEndTagName(); break; case HtmlTokenizerState.ScriptDataEscapeStart: ReadScriptDataEscapeStart(); break; case HtmlTokenizerState.ScriptDataEscapeStartDash: ReadScriptDataEscapeStartDash(); break; case HtmlTokenizerState.ScriptDataEscaped: ReadScriptDataEscaped(); break; case HtmlTokenizerState.ScriptDataEscapedDash: ReadScriptDataEscapedDash(); break; case HtmlTokenizerState.ScriptDataEscapedDashDash: ReadScriptDataEscapedDashDash(); break; case HtmlTokenizerState.ScriptDataEscapedLessThan: ReadScriptDataEscapedLessThan(); break; case HtmlTokenizerState.ScriptDataEscapedEndTagOpen: ReadScriptDataEscapedEndTagOpen(); break; case HtmlTokenizerState.ScriptDataEscapedEndTagName: ReadScriptDataEscapedEndTagName(); break; case HtmlTokenizerState.ScriptDataDoubleEscapeStart: ReadScriptDataDoubleEscapeStart(); break; case HtmlTokenizerState.ScriptDataDoubleEscaped: ReadScriptDataDoubleEscaped(); break; case HtmlTokenizerState.ScriptDataDoubleEscapedDash: ReadScriptDataDoubleEscapedDash(); break; case HtmlTokenizerState.ScriptDataDoubleEscapedDashDash: ReadScriptDataDoubleEscapedDashDash(); break; case HtmlTokenizerState.ScriptDataDoubleEscapedLessThan: ReadScriptDataDoubleEscapedLessThan(); break; case HtmlTokenizerState.ScriptDataDoubleEscapeEnd: ReadScriptDataDoubleEscapeEnd(); break; case HtmlTokenizerState.BeforeAttributeName: ReadBeforeAttributeName(); break; case HtmlTokenizerState.AttributeName: ReadAttributeName(); break; case HtmlTokenizerState.AfterAttributeName: ReadAfterAttributeName(); break; case HtmlTokenizerState.BeforeAttributeValue: ReadBeforeAttributeValue(); break; case HtmlTokenizerState.AttributeValueQuoted: ReadAttributeValueQuoted(); break; case HtmlTokenizerState.AttributeValueUnquoted: ReadAttributeValueUnquoted(); break; case HtmlTokenizerState.CharacterReferenceInAttributeValue: ReadCharacterReferenceInAttributeValue(); break; case HtmlTokenizerState.AfterAttributeValueQuoted: ReadAfterAttributeValueQuoted(); break; case HtmlTokenizerState.SelfClosingStartTag: ReadSelfClosingStartTag(); break; case HtmlTokenizerState.BogusComment: ReadBogusComment(); break; case HtmlTokenizerState.MarkupDeclarationOpen: ReadMarkupDeclarationOpen(); break; case HtmlTokenizerState.CommentStart: ReadCommentStart(); break; case HtmlTokenizerState.CommentStartDash: ReadCommentStartDash(); break; case HtmlTokenizerState.Comment: ReadComment(); break; case HtmlTokenizerState.CommentEndDash: ReadCommentEndDash(); break; case HtmlTokenizerState.CommentEnd: ReadCommentEnd(); break; case HtmlTokenizerState.CommentEndBang: ReadCommentEndBang(); break; case HtmlTokenizerState.DocType: ReadDocType(); break; case HtmlTokenizerState.BeforeDocTypeName: ReadBeforeDocTypeName(); break; case HtmlTokenizerState.DocTypeName: ReadDocTypeName(); break; case HtmlTokenizerState.AfterDocTypeName: ReadAfterDocTypeName(); break; case HtmlTokenizerState.AfterDocTypePublicKeyword: ReadAfterDocTypePublicKeyword(); break; case HtmlTokenizerState.BeforeDocTypePublicIdentifier: ReadBeforeDocTypePublicIdentifier(); break; case HtmlTokenizerState.DocTypePublicIdentifierQuoted: ReadDocTypePublicIdentifierQuoted(); break; case HtmlTokenizerState.AfterDocTypePublicIdentifier: ReadAfterDocTypePublicIdentifier(); break; case HtmlTokenizerState.BetweenDocTypePublicAndSystemIdentifiers: ReadBetweenDocTypePublicAndSystemIdentifiers(); break; case HtmlTokenizerState.AfterDocTypeSystemKeyword: ReadAfterDocTypeSystemKeyword(); break; case HtmlTokenizerState.BeforeDocTypeSystemIdentifier: ReadBeforeDocTypeSystemIdentifier(); break; case HtmlTokenizerState.DocTypeSystemIdentifierQuoted: ReadDocTypeSystemIdentifierQuoted(); break; case HtmlTokenizerState.AfterDocTypeSystemIdentifier: ReadAfterDocTypeSystemIdentifier(); break; case HtmlTokenizerState.BogusDocType: ReadBogusDocType(); break; case HtmlTokenizerState.CDataSection: ReadCDataSection(); break; case HtmlTokenizerState.EndOfFile: output = token = null; return(false); } if ((output = token) != null) { return(true);//found next token } } //3. output = token = null; return(false); }
/// <summary> /// Write a token to the output stream. /// </summary> /// <remarks> /// Writes a token that was emitted by the <see cref="HtmlTokenizer"/> /// to the output stream. /// </remarks> /// <param name="token">The HTML token.</param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="token"/> is <c>null</c>. /// </exception> /// <exception cref="System.ObjectDisposedException"> /// The <see cref="HtmlWriter"/> has been disposed. /// </exception> public void WriteToken (HtmlToken token) { if (token == null) throw new ArgumentNullException ("token"); CheckDisposed (); if (WriterState != HtmlWriterState.Default) { WriterState = HtmlWriterState.Default; html.Write (empty ? "/>" : ">"); empty = false; } token.WriteTo (html); }
/// <summary> /// Reads the next token. /// </summary> /// <remarks> /// Reads the next token. /// </remarks> /// <returns><c>true</c> if the next token was read; otherwise, <c>false</c>.</returns> /// <param name="token">THe token that was read.</param> public bool ReadNextToken(out HtmlToken token) { do { switch (TokenizerState) { case HtmlTokenizerState.Data: token = ReadData (); break; case HtmlTokenizerState.CharacterReferenceInData: token = ReadCharacterReferenceInData (); break; case HtmlTokenizerState.RcData: token = ReadRcData (); break; case HtmlTokenizerState.CharacterReferenceInRcData: token = ReadCharacterReferenceInRcData (); break; case HtmlTokenizerState.RawText: token = ReadRawText (); break; case HtmlTokenizerState.ScriptData: token = ReadScriptData (); break; case HtmlTokenizerState.PlainText: token = ReadPlainText (); break; case HtmlTokenizerState.TagOpen: token = ReadTagOpen (); break; case HtmlTokenizerState.EndTagOpen: token = ReadEndTagOpen (); break; case HtmlTokenizerState.TagName: token = ReadTagName (); break; case HtmlTokenizerState.RcDataLessThan: token = ReadRcDataLessThan (); break; case HtmlTokenizerState.RcDataEndTagOpen: token = ReadRcDataEndTagOpen (); break; case HtmlTokenizerState.RcDataEndTagName: token = ReadRcDataEndTagName (); break; case HtmlTokenizerState.RawTextLessThan: token = ReadRawTextLessThan (); break; case HtmlTokenizerState.RawTextEndTagOpen: token = ReadRawTextEndTagOpen (); break; case HtmlTokenizerState.RawTextEndTagName: token = ReadRawTextEndTagName (); break; case HtmlTokenizerState.ScriptDataLessThan: token = ReadScriptDataLessThan (); break; case HtmlTokenizerState.ScriptDataEndTagOpen: token = ReadScriptDataEndTagOpen (); break; case HtmlTokenizerState.ScriptDataEndTagName: token = ReadScriptDataEndTagName (); break; case HtmlTokenizerState.ScriptDataEscapeStart: token = ReadScriptDataEscapeStart (); break; case HtmlTokenizerState.ScriptDataEscapeStartDash: token = ReadScriptDataEscapeStartDash (); break; case HtmlTokenizerState.ScriptDataEscaped: token = ReadScriptDataEscaped (); break; case HtmlTokenizerState.ScriptDataEscapedDash: token = ReadScriptDataEscapedDash (); break; case HtmlTokenizerState.ScriptDataEscapedDashDash: token = ReadScriptDataEscapedDashDash (); break; case HtmlTokenizerState.ScriptDataEscapedLessThan: token = ReadScriptDataEscapedLessThan (); break; case HtmlTokenizerState.ScriptDataEscapedEndTagOpen: token = ReadScriptDataEscapedEndTagOpen (); break; case HtmlTokenizerState.ScriptDataEscapedEndTagName: token = ReadScriptDataEscapedEndTagName (); break; case HtmlTokenizerState.ScriptDataDoubleEscapeStart: token = ReadScriptDataDoubleEscapeStart (); break; case HtmlTokenizerState.ScriptDataDoubleEscaped: token = ReadScriptDataDoubleEscaped (); break; case HtmlTokenizerState.ScriptDataDoubleEscapedDash: token = ReadScriptDataDoubleEscapedDash (); break; case HtmlTokenizerState.ScriptDataDoubleEscapedDashDash: token = ReadScriptDataDoubleEscapedDashDash (); break; case HtmlTokenizerState.ScriptDataDoubleEscapedLessThan: token = ReadScriptDataDoubleEscapedLessThan (); break; case HtmlTokenizerState.ScriptDataDoubleEscapeEnd: token = ReadScriptDataDoubleEscapeEnd (); break; case HtmlTokenizerState.BeforeAttributeName: token = ReadBeforeAttributeName (); break; case HtmlTokenizerState.AttributeName: token = ReadAttributeName (); break; case HtmlTokenizerState.AfterAttributeName: token = ReadAfterAttributeName (); break; case HtmlTokenizerState.BeforeAttributeValue: token = ReadBeforeAttributeValue (); break; case HtmlTokenizerState.AttributeValueQuoted: token = ReadAttributeValueQuoted (); break; case HtmlTokenizerState.AttributeValueUnquoted: token = ReadAttributeValueUnquoted (); break; case HtmlTokenizerState.CharacterReferenceInAttributeValue: token = ReadCharacterReferenceInAttributeValue (); break; case HtmlTokenizerState.AfterAttributeValueQuoted: token = ReadAfterAttributeValueQuoted (); break; case HtmlTokenizerState.SelfClosingStartTag: token = ReadSelfClosingStartTag (); break; case HtmlTokenizerState.BogusComment: token = ReadBogusComment (); break; case HtmlTokenizerState.MarkupDeclarationOpen: token = ReadMarkupDeclarationOpen (); break; case HtmlTokenizerState.CommentStart: token = ReadCommentStart (); break; case HtmlTokenizerState.CommentStartDash: token = ReadCommentStartDash (); break; case HtmlTokenizerState.Comment: token = ReadComment (); break; case HtmlTokenizerState.CommentEndDash: token = ReadCommentEndDash (); break; case HtmlTokenizerState.CommentEnd: token = ReadCommentEnd (); break; case HtmlTokenizerState.CommentEndBang: token = ReadCommentEndBang (); break; case HtmlTokenizerState.DocType: token = ReadDocType (); break; case HtmlTokenizerState.BeforeDocTypeName: token = ReadBeforeDocTypeName (); break; case HtmlTokenizerState.DocTypeName: token = ReadDocTypeName (); break; case HtmlTokenizerState.AfterDocTypeName: token = ReadAfterDocTypeName (); break; case HtmlTokenizerState.AfterDocTypePublicKeyword: token = ReadAfterDocTypePublicKeyword (); break; case HtmlTokenizerState.BeforeDocTypePublicIdentifier: token = ReadBeforeDocTypePublicIdentifier (); break; case HtmlTokenizerState.DocTypePublicIdentifierQuoted: token = ReadDocTypePublicIdentifierQuoted (); break; case HtmlTokenizerState.AfterDocTypePublicIdentifier: token = ReadAfterDocTypePublicIdentifier (); break; case HtmlTokenizerState.BetweenDocTypePublicAndSystemIdentifiers: token = ReadBetweenDocTypePublicAndSystemIdentifiers (); break; case HtmlTokenizerState.AfterDocTypeSystemKeyword: token = ReadAfterDocTypeSystemKeyword (); break; case HtmlTokenizerState.BeforeDocTypeSystemIdentifier: token = ReadBeforeDocTypeSystemIdentifier (); break; case HtmlTokenizerState.DocTypeSystemIdentifierQuoted: token = ReadDocTypeSystemIdentifierQuoted (); break; case HtmlTokenizerState.AfterDocTypeSystemIdentifier: token = ReadAfterDocTypeSystemIdentifier (); break; case HtmlTokenizerState.BogusDocType: token = ReadBogusDocType (); break; case HtmlTokenizerState.CDataSection: token = ReadCDataSection (); break; case HtmlTokenizerState.EndOfFile: default: token = null; return false; } } while (token == null); return true; }
public bool ReadNextToken(out HtmlToken output) { token = null; while (TokenizerState != HtmlTokenizerState.EndOfFile) { switch (TokenizerState) { case HtmlTokenizerState.Data: R01_DataToken(); break; case HtmlTokenizerState.CharacterReferenceInData: R02_CharacterReferenceInData(); break; case HtmlTokenizerState.RcData: R03_RcData(); break; case HtmlTokenizerState.CharacterReferenceInRcData: R04_CharacterReferenceInRcData(); break; case HtmlTokenizerState.RawText: R05_RawText(); break; case HtmlTokenizerState.ScriptData: R06_ScriptData(); break; case HtmlTokenizerState.PlainText: R07_PlainText(); break; case HtmlTokenizerState.TagOpen: R08_TagOpen(); break; case HtmlTokenizerState.EndTagOpen: R09_EndTagOpen(); break; case HtmlTokenizerState.TagName: R10_TagName(); break; case HtmlTokenizerState.RcDataLessThan: R11_RcDataLessThan(); break; case HtmlTokenizerState.RcDataEndTagOpen: R12_RcDataEndTagOpen(); break; case HtmlTokenizerState.RcDataEndTagName: R13_RcDataEndTagName(); break; case HtmlTokenizerState.RawTextLessThan: R14_RawTextLessThan(); break; case HtmlTokenizerState.RawTextEndTagOpen: R15_RawTextEndTagOpen(); break; case HtmlTokenizerState.RawTextEndTagName: R16_RawTextEndTagName(); break; case HtmlTokenizerState.ScriptDataLessThan: R17_ScriptDataLessThan(); break; case HtmlTokenizerState.ScriptDataEndTagOpen: R18_ScriptDataEndTagOpen(); break; case HtmlTokenizerState.ScriptDataEndTagName: R19_ScriptDataEndTagName(); break; case HtmlTokenizerState.ScriptDataEscapeStart: R20_ScriptDataEscapeStart(); break; case HtmlTokenizerState.ScriptDataEscapeStartDash: R21_ScriptDataEscapeStartDash(); break; case HtmlTokenizerState.ScriptDataEscaped: R22_ScriptDataEscaped(); break; case HtmlTokenizerState.ScriptDataEscapedDash: R23_ScriptDataEscapedDash(); break; case HtmlTokenizerState.ScriptDataEscapedDashDash: R24_ScriptDataEscapedDashDash(); break; case HtmlTokenizerState.ScriptDataEscapedLessThan: R25_ScriptDataEscapedLessThan(); break; case HtmlTokenizerState.ScriptDataEscapedEndTagOpen: R26_ScriptDataEscapedEndTagOpen(); break; case HtmlTokenizerState.ScriptDataEscapedEndTagName: R27_ScriptDataEscapedEndTagName(); break; case HtmlTokenizerState.ScriptDataDoubleEscapeStart: R28_ScriptDataDoubleEscapeStart(); break; case HtmlTokenizerState.ScriptDataDoubleEscaped: R29_ScriptDataDoubleEscaped(); break; case HtmlTokenizerState.ScriptDataDoubleEscapedDash: R30_ScriptDataDoubleEscapedDash(); break; case HtmlTokenizerState.ScriptDataDoubleEscapedDashDash: R31_ScriptDataDoubleEscapedDashDash(); break; case HtmlTokenizerState.ScriptDataDoubleEscapedLessThan: R32_ScriptDataDoubleEscapedLessThan(); break; case HtmlTokenizerState.ScriptDataDoubleEscapeEnd: R33_ScriptDataDoubleEscapeEnd(); break; case HtmlTokenizerState.BeforeAttributeName: R34_BeforeAttributeName(); break; case HtmlTokenizerState.AttributeName: R35_AttributeName(); break; case HtmlTokenizerState.AfterAttributeName: R36_AfterAttributeName(); break; case HtmlTokenizerState.BeforeAttributeValue: R37_BeforeAttributeValue(); break; case HtmlTokenizerState.AttributeValueQuoted: R38_39_AttributeValueQuoted(); break; case HtmlTokenizerState.AttributeValueUnquoted: R40_AttributeValueUnquoted(); break; case HtmlTokenizerState.CharacterReferenceInAttributeValue: R41_CharacterReferenceInAttributeValue(); break; case HtmlTokenizerState.AfterAttributeValueQuoted: R42_AfterAttributeValueQuoted(); break; case HtmlTokenizerState.SelfClosingStartTag: R43_SelfClosingStartTag(); break; case HtmlTokenizerState.BogusComment: R44_BogusComment(); break; case HtmlTokenizerState.MarkupDeclarationOpen: R45_MarkupDeclarationOpen(); break; case HtmlTokenizerState.CommentStart: R46_CommentStart(); break; case HtmlTokenizerState.CommentStartDash: R47_CommentStartDash(); break; case HtmlTokenizerState.Comment: R48_Comment(); break; case HtmlTokenizerState.CommentEndDash: R49_CommentEndDash(); break; case HtmlTokenizerState.CommentEnd: R50_CommentEnd(); break; case HtmlTokenizerState.CommentEndBang: R51_CommentEndBang(); break; case HtmlTokenizerState.DocType: R52_DocType(); break; case HtmlTokenizerState.BeforeDocTypeName: R53_BeforeDocTypeName(); break; case HtmlTokenizerState.DocTypeName: R54_DocTypeName(); break; case HtmlTokenizerState.AfterDocTypeName: R55_AfterDocTypeName(); break; case HtmlTokenizerState.AfterDocTypePublicKeyword: R56_AfterDocTypePublicKeyword(); break; case HtmlTokenizerState.BeforeDocTypePublicIdentifier: R57_BeforeDocTypePublicIdentifier(); break; case HtmlTokenizerState.DocTypePublicIdentifierQuoted: R58_59_DocTypePublicIdentifierQuoted(); break; case HtmlTokenizerState.AfterDocTypePublicIdentifier: R60_AfterDocTypePublicIdentifier(); break; case HtmlTokenizerState.BetweenDocTypePublicAndSystemIdentifiers: R61_BetweenDocTypePublicAndSystemIdentifiers(); break; case HtmlTokenizerState.AfterDocTypeSystemKeyword: R62_AfterDocTypeSystemKeyword(); break; case HtmlTokenizerState.BeforeDocTypeSystemIdentifier: R63_BeforeDocTypeSystemIdentifier(); break; case HtmlTokenizerState.DocTypeSystemIdentifierQuoted: R64_65_DocTypeSystemIdentifierQuoted(); break; case HtmlTokenizerState.AfterDocTypeSystemIdentifier: R66_AfterDocTypeSystemIdentifier(); break; case HtmlTokenizerState.BogusDocType: R67_BogusDocType(); break; case HtmlTokenizerState.CDataSection: R68_CDataSection(); break; case HtmlTokenizerState.EndOfFile: output = token = null; return false; } if ((output = token) != null) { return true;//found next token } } //3. output = token = null; return false; }
void ResetEmittingToken() { _nextEmitToken = null; }
void SetEmitToken(HtmlToken token) { this._nextEmitToken = token; }