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


C# Node.FindDocType方法代码示例

本文整理汇总了C#中TidyNet.Node.FindDocType方法的典型用法代码示例。如果您正苦于以下问题:C# Node.FindDocType方法的具体用法?C# Node.FindDocType怎么用?C# Node.FindDocType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TidyNet.Node的用法示例。


在下文中一共展示了Node.FindDocType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixDocType

		/* fixup doctype if missing */
		public virtual bool FixDocType(Node root)
		{
			Node doctype;
			HtmlVersion guessed = HtmlVersion.Html40Strict;
			int i;
			
			if (this.badDoctype)
			{
				Report.Warning(this, null, null, Report.MALFORMED_DOCTYPE);
			}
			
			if (Options.XmlOut)
			{
				return true;
			}
			
			doctype = root.FindDocType();
			
			if (Options.DocType == TidyNet.DocType.Omit)
			{
				if (doctype != null)
				{
					Node.DiscardElement(doctype);
				}
				return true;
			}
			
			if (Options.DocType == TidyNet.DocType.Strict)
			{
				Node.DiscardElement(doctype);
				doctype = null;
				guessed = HtmlVersion.Html40Strict;
			}
			else if (Options.DocType == TidyNet.DocType.Loose)
			{
				Node.DiscardElement(doctype);
				doctype = null;
				guessed = HtmlVersion.Html40Loose;
			}
			else if (Options.DocType == TidyNet.DocType.Auto)
			{
				if (doctype != null)
				{
					if (this.doctype == HtmlVersion.Unknown)
					{
						return false;
					}

					switch (this.doctype)
					{
					case HtmlVersion.Unknown:
						return false;

					case HtmlVersion.Html20:
						if ((this.versions & HtmlVersion.Html20) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Html32:
						if ((this.versions & HtmlVersion.Html32) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Html40Strict:
						if ((this.versions & HtmlVersion.Html40Strict) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Html40Loose:
						if ((this.versions & HtmlVersion.Html40Loose) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
						
						
					case HtmlVersion.Frames:
						if ((this.versions & HtmlVersion.Frames) != 0)
						{
							return true;
						}
						break; /* to replace old version by new */
					}
					
					/* INCONSISTENT_VERSION warning is now issued by ApparentVersion() */
				}
				
				/* choose new doctype */
				guessed = GetHtmlVersion();
			}
//.........这里部分代码省略.........
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:101,代码来源:Lexer.cs

示例2: SetXhtmlDocType

		public virtual bool SetXhtmlDocType(Node root)
		{
			string fpi = " ";
			string sysid = "";
			string namespace_Renamed = XHTML_NAMESPACE;
			Node doctype;
			
			doctype = root.FindDocType();
			
			if (Options.DocType == TidyNet.DocType.Omit)
			{
				if (doctype != null)
					Node.DiscardElement(doctype);
				return true;
			}
			
			if (Options.DocType == TidyNet.DocType.Auto)
			{
				/* see what flavor of XHTML this document matches */
				if ((this.versions & HtmlVersion.Html40Strict) != 0)
				{
					/* use XHTML strict */
					fpi = "-//W3C//DTD XHTML 1.0 Strict//EN";
					sysid = voyager_strict;
				}
				else if ((this.versions & HtmlVersion.Loose) != 0)
				{
					fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
					sysid = voyager_loose;
				}
				else if ((this.versions & HtmlVersion.Frames) != 0)
				{
					/* use XHTML frames */
					fpi = "-//W3C//DTD XHTML 1.0 Frameset//EN";
					sysid = voyager_frameset;
				}
				else
				{
					/* lets assume XHTML transitional */
					fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
					sysid = voyager_loose;
				}
			}
			else if (Options.DocType == TidyNet.DocType.Strict)
			{
				fpi = "-//W3C//DTD XHTML 1.0 Strict//EN";
				sysid = voyager_strict;
			}
			else if (Options.DocType == TidyNet.DocType.Loose)
			{
				fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
				sysid = voyager_loose;
			}
			
			FixHtmlNameSpace(root, namespace_Renamed);
			
			if (doctype == null)
			{
				doctype = NewNode(Node.DocTypeTag, this.lexbuf, 0, 0);
				doctype.Next = root.Content;
				doctype.Parent = root;
				doctype.Prev = null;
				root.Content = doctype;
			}
			
			if (Options.DocType == TidyNet.DocType.User && Options.DocTypeStr != null)
			{
				fpi = Options.DocTypeStr;
				sysid = "";
			}
			
			this.txtstart = this.lexsize;
			this.txtend = this.lexsize;
			
			/* add public identifier */
			AddStringLiteral("html PUBLIC ");
			
			/* check if the fpi is quoted or not */
			if (fpi[0] == '"')
			{
				AddStringLiteral(fpi);
			}
			else
			{
				AddStringLiteral("\"");
				AddStringLiteral(fpi);
				AddStringLiteral("\"");
			}
			
			if (sysid.Length + 6 >= this.Options.WrapLen)
			{
				AddStringLiteral("\n\"");
			}
			else
			{
				AddStringLiteral("\n    \"");
			}

			/* add system identifier */
			AddStringLiteral(sysid);
//.........这里部分代码省略.........
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:101,代码来源:Lexer.cs


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