本文整理汇总了C#中ParserContext.AdjustForWhitespace方法的典型用法代码示例。如果您正苦于以下问题:C# ParserContext.AdjustForWhitespace方法的具体用法?C# ParserContext.AdjustForWhitespace怎么用?C# ParserContext.AdjustForWhitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserContext
的用法示例。
在下文中一共展示了ParserContext.AdjustForWhitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadNext
static void ReadNext(ParserContext context)
{
while(!context.EndOfString)
{
Match match;
if (context.InScriptTag)
{
match = RxNextScriptToken.Match(context.Html, context.Index);
if (match.Groups["close"].Success)
{
context.InScriptTag = false;
}
}
else
{
match = RxNextToken.Match(context.Html, context.Index);
}
if(match.Success)
{
var len = match.Index - context.Index;
if(len > 0)
{
var str = context.Html.Substring(context.Index, len);
context.Tokens.Add(new HtmlParserToken { Type = TokenType.Text, A = context.AdjustForWhitespace(str), Raw = str });
context.Index += len;
}
if(match.Groups["xmldecl"].Success)
ReadXmlDeclaration(context);
else if(match.Groups["doctype"].Success)
ReadDocTypeDeclaration(context);
else if(match.Groups["comment"].Success)
ReadComment(context);
else if(match.Groups["close"].Success)
ReadCloseElement(context);
else if(match.Groups["cdata"].Success)
ReadCdata(context);
else if (match.Groups["conditional"].Success)
ReadConditional(context);
else
ReadElement(context);
}
else
{
var str = context.Html.Substring(context.Index);
context.Tokens.Add(new HtmlParserToken { Type = TokenType.Text, A = context.AdjustForWhitespace(str), Raw = str });
return;
}
}
}
示例2: ReadCloseElement
private static void ReadCloseElement(ParserContext context)
{
var match = RxReadCloseAttribute.Match(context.Html, context.Index);
if(!match.Success)
{
var str = context.Html.Substring(context.Index);
context.Tokens.Add(new HtmlParserToken { Type = TokenType.Text, A = context.AdjustForWhitespace(str), Raw = str });
context.Index = context.Html.Length;
}
else
{
var newToken = new HtmlParserToken { Type = TokenType.CloseElement, Raw = match.Value, A = match.Groups["name"].Value };
context.Tokens.Add(newToken);
//HACK there might be a tag inside of a tag (Incorrectly closed tag) like </strong</td>
//If we find this, we are going to adjust
if (newToken.A.IndexOf("<") > -1)
{
var index = match.Value.Substring(2).IndexOf("<");
newToken.A = newToken.A.Substring(0, index);
context.Index += index + 2;
}
else
{
context.Index += match.Length;
}
}
}
示例3: ReadCloseElement
private static void ReadCloseElement(ParserContext context)
{
var match = RxReadCloseAttribute.Match(context.Html, context.Index);
if(!match.Success)
{
var str = context.Html.Substring(context.Index);
context.Tokens.Add(new HtmlParserToken { Type = TokenType.Text, A = context.AdjustForWhitespace(str), Raw = str });
context.Index = context.Html.Length;
}
else
{
context.Tokens.Add(new HtmlParserToken { Type = TokenType.CloseElement, Raw = match.Value, A = match.Groups["name"].Value });
context.Index += match.Length;
}
}