本文整理汇总了C#中HtmlTokenizerState类的典型用法代码示例。如果您正苦于以下问题:C# HtmlTokenizerState类的具体用法?C# HtmlTokenizerState怎么用?C# HtmlTokenizerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlTokenizerState类属于命名空间,在下文中一共展示了HtmlTokenizerState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadGenericRawTextEndTagOpen
void ReadGenericRawTextEndTagOpen(bool decoded, HtmlTokenizerState rawText, HtmlTokenizerState rawTextEndTagName)
{
char c;
CharMode charMode;
if (!Peek(out c, out charMode))
{
TokenizerState = HtmlTokenizerState.EndOfFile;
EmitDataToken(decoded);
return;
}
switch (charMode)
{
//IsAsciiLetter(c)
case CharMode.UpperAsciiLetter:
case CharMode.LowerAsciiLetter:
TokenizerState = rawTextEndTagName;
name.Append(c);
data.Append(c);
ReadNext();
break;
default:
TokenizerState = rawText;
break;
}
}
示例2: ReadGenericRawTextLessThan
void ReadGenericRawTextLessThan(HtmlTokenizerState rawText, HtmlTokenizerState rawTextEndTagOpen)
{
char c;
if (!Peek(out c))
{
//?
throw new System.NotSupportedException();
}
data.Append('<');
switch (c)
{
case '/':
TokenizerState = rawTextEndTagOpen;
data.Append('/');
name.Length = 0;
ReadNext();
break;
default:
TokenizerState = rawText;
break;
}
}
示例3: ReadScriptDataEscapeStartDash
// 8.2.4.21 Script data escape start dash state
HtmlToken ReadScriptDataEscapeStartDash ()
{
int nc = Peek ();
if (nc == '-') {
TokenizerState = HtmlTokenizerState.ScriptDataEscapedDashDash;
data.Append ('-');
Read ();
} else {
TokenizerState = HtmlTokenizerState.ScriptData;
}
return null;
}
示例4: ReadScriptDataEndTagOpen
// 8.2.4.18 Script data end tag open state
HtmlToken ReadScriptDataEndTagOpen ()
{
int nc = Peek ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
return EmitScriptDataToken ();
}
c = (char) nc;
if (c == 'S' || c == 's') {
TokenizerState = HtmlTokenizerState.ScriptDataEndTagName;
name.Append ('s');
data.Append (c);
Read ();
} else {
TokenizerState = HtmlTokenizerState.ScriptData;
}
return null;
}
示例5: ReadTagName
// 8.2.4.10 Tag name state
HtmlToken ReadTagName ()
{
do {
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
name.Length = 0;
return EmitDataToken (false);
}
c = (char) nc;
// Note: we save the data in case we hit a parse error and have to emit a data token
data.Append (c);
switch (c) {
case '\t': case '\r': case '\n': case '\f': case ' ':
TokenizerState = HtmlTokenizerState.BeforeAttributeName;
break;
case '/':
TokenizerState = HtmlTokenizerState.SelfClosingStartTag;
break;
case '>':
tag = CreateTagToken (name.ToString (), isEndTag);
data.Length = 0;
name.Length = 0;
return EmitTagToken ();
default:
name.Append (c == '\0' ? '\uFFFD' : c);
break;
}
} while (TokenizerState == HtmlTokenizerState.TagName);
tag = CreateTagToken (name.ToString (), isEndTag);
name.Length = 0;
return null;
}
示例6: ReadTagOpen
// 8.2.4.8 Tag open state
HtmlToken ReadTagOpen ()
{
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
var token = CreateDataToken ("<");
return token;
}
c = (char) nc;
// Note: we save the data in case we hit a parse error and have to emit a data token
data.Append ('<');
data.Append (c);
switch ((c = (char) nc)) {
case '!': TokenizerState = HtmlTokenizerState.MarkupDeclarationOpen; break;
case '?': TokenizerState = HtmlTokenizerState.BogusComment; break;
case '/': TokenizerState = HtmlTokenizerState.EndTagOpen; break;
default:
if (IsAsciiLetter (c)) {
TokenizerState = HtmlTokenizerState.TagName;
isEndTag = false;
name.Append (c);
} else {
TokenizerState = HtmlTokenizerState.Data;
}
break;
}
return null;
}
示例7: ReadScriptData
// 8.2.4.6 Script data state
HtmlToken ReadScriptData ()
{
do {
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
break;
}
c = (char) nc;
switch (c) {
case '<':
TokenizerState = HtmlTokenizerState.ScriptDataLessThan;
break;
default:
data.Append (c == '\0' ? '\uFFFD' : c);
break;
}
} while (TokenizerState == HtmlTokenizerState.ScriptData);
return EmitScriptDataToken ();
}
示例8: ReadRcData
// 8.2.4.3 RCDATA state
HtmlToken ReadRcData ()
{
do {
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
break;
}
c = (char) nc;
switch (c) {
case '&':
if (DecodeCharacterReferences) {
TokenizerState = HtmlTokenizerState.CharacterReferenceInRcData;
return null;
}
goto default;
case '<':
TokenizerState = HtmlTokenizerState.RcDataLessThan;
return EmitDataToken (DecodeCharacterReferences);
default:
data.Append (c == '\0' ? '\uFFFD' : c);
break;
}
} while (TokenizerState == HtmlTokenizerState.RcData);
return EmitDataToken (DecodeCharacterReferences);
}
示例9: ReadAfterDocTypeSystemKeyword
// 8.2.4.62 After DOCTYPE system keyword state
HtmlToken ReadAfterDocTypeSystemKeyword ()
{
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
doctype.ForceQuirksMode = true;
return EmitDocType ();
}
c = (char) nc;
// Note: we save the data in case we hit a parse error and have to emit a data token
data.Append (c);
switch (c) {
case '\t': case '\r': case '\n': case '\f': case ' ':
TokenizerState = HtmlTokenizerState.BeforeDocTypeSystemIdentifier;
break;
case '"': case '\'': // parse error
TokenizerState = HtmlTokenizerState.DocTypeSystemIdentifierQuoted;
doctype.SystemIdentifier = string.Empty;
quote = c;
break;
case '>': // parse error
TokenizerState = HtmlTokenizerState.Data;
doctype.ForceQuirksMode = true;
return EmitDocType ();
default: // parse error
TokenizerState = HtmlTokenizerState.BogusDocType;
doctype.ForceQuirksMode = true;
break;
}
return null;
}
示例10: ReadAfterDocTypeName
// 8.2.4.55 After DOCTYPE name state
HtmlToken ReadAfterDocTypeName ()
{
do {
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
doctype.ForceQuirksMode = true;
return EmitDocType ();
}
c = (char) nc;
// Note: we save the data in case we hit a parse error and have to emit a data token
data.Append (c);
switch (c) {
case '\t': case '\r': case '\n': case '\f': case ' ':
break;
case '>':
TokenizerState = HtmlTokenizerState.Data;
return EmitDocType ();
default:
name.Append (c);
if (name.Length < 6)
break;
if (NameIs ("public")) {
TokenizerState = HtmlTokenizerState.AfterDocTypePublicKeyword;
doctype.PublicKeyword = name.ToString ();
} else if (NameIs ("system")) {
TokenizerState = HtmlTokenizerState.AfterDocTypeSystemKeyword;
doctype.SystemKeyword = name.ToString ();
} else {
TokenizerState = HtmlTokenizerState.BogusDocType;
}
name.Length = 0;
return null;
}
} while (true);
}
示例11: ReadDocTypeName
// 8.2.4.54 DOCTYPE name state
HtmlToken ReadDocTypeName ()
{
do {
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
doctype.Name = name.ToString ();
doctype.ForceQuirksMode = true;
name.Length = 0;
return EmitDocType ();
}
c = (char) nc;
// Note: we save the data in case we hit a parse error and have to emit a data token
data.Append (c);
switch (c) {
case '\t': case '\r': case '\n': case '\f': case ' ':
TokenizerState = HtmlTokenizerState.AfterDocTypeName;
break;
case '>':
TokenizerState = HtmlTokenizerState.Data;
doctype.Name = name.ToString ();
name.Length = 0;
return EmitDocType ();
case '\0':
name.Append ('\uFFFD');
break;
default:
name.Append (c);
break;
}
} while (TokenizerState == HtmlTokenizerState.DocTypeName);
doctype.Name = name.ToString ();
name.Length = 0;
return null;
}
示例12: ReadDocType
// 8.2.4.52 DOCTYPE state
HtmlToken ReadDocType ()
{
int nc = Peek ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
doctype.ForceQuirksMode = true;
name.Length = 0;
return EmitDocType ();
}
TokenizerState = HtmlTokenizerState.BeforeDocTypeName;
c = (char) nc;
switch (c) {
case '\t': case '\r': case '\n': case '\f': case ' ':
data.Append (c);
Read ();
break;
}
return null;
}
示例13: ReadCommentEndBang
// 8.2.4.51 Comment end bang state
HtmlToken ReadCommentEndBang ()
{
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
return EmitCommentToken (name);
}
c = (char) nc;
data.Append (c);
switch (c) {
case '-':
TokenizerState = HtmlTokenizerState.CommentEndDash;
name.Append ("--!");
break;
case '>':
TokenizerState = HtmlTokenizerState.Data;
return EmitCommentToken (name);
default: // parse error
TokenizerState = HtmlTokenizerState.Comment;
name.Append ("--!");
name.Append (c == '\0' ? '\uFFFD' : c);
break;
}
return null;
}
示例14: ReadCommentEnd
// 8.2.4.50 Comment end state
HtmlToken ReadCommentEnd ()
{
do {
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.EndOfFile;
return EmitCommentToken (name);
}
c = (char) nc;
// Note: we save the data in case we hit a parse error and have to emit a data token
data.Append (c);
switch (c) {
case '>':
TokenizerState = HtmlTokenizerState.Data;
return EmitCommentToken (name);
case '!': // parse error
TokenizerState = HtmlTokenizerState.CommentEndBang;
return null;
case '-':
name.Append ('-');
break;
default:
TokenizerState = HtmlTokenizerState.Comment;
name.Append (c == '\0' ? '\uFFFD' : c);
return null;
}
} while (true);
}
示例15: ReadCommentEndDash
// 8.2.4.49 Comment end dash state
HtmlToken ReadCommentEndDash ()
{
int nc = Read ();
char c;
if (nc == -1) {
TokenizerState = HtmlTokenizerState.Data;
return EmitCommentToken (name);
}
c = (char) nc;
data.Append (c);
switch (c) {
case '-':
TokenizerState = HtmlTokenizerState.CommentEnd;
break;
default:
TokenizerState = HtmlTokenizerState.Comment;
name.Append ('-');
name.Append (c == '\0' ? '\uFFFD' : c);
break;
}
return null;
}