当前位置: 首页>>代码示例>>C#>>正文


C# ParserContext.AdjustForWhitespace方法代码示例

本文整理汇总了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;
				}
			}
		}
开发者ID:AshWilliams,项目名称:SimpleBrowser,代码行数:51,代码来源:HtmlTokenizer.cs

示例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;
				}
			}
		}
开发者ID:AshWilliams,项目名称:SimpleBrowser,代码行数:27,代码来源:HtmlTokenizer.cs

示例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;
     }
 }
开发者ID:johnnonolan,项目名称:SimpleBrowser,代码行数:15,代码来源:HtmlTokenizer.cs


注:本文中的ParserContext.AdjustForWhitespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。