本文整理汇总了C#中Tidy.Core.Node.FindDocType方法的典型用法代码示例。如果您正苦于以下问题:C# Node.FindDocType方法的具体用法?C# Node.FindDocType怎么用?C# Node.FindDocType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tidy.Core.Node
的用法示例。
在下文中一共展示了Node.FindDocType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixDocType
/* fixup doctype if missing */
public virtual bool FixDocType(Node root)
{
var guessed = HtmlVersion.Html40Strict;
int i;
if (BadDoctype)
{
Report.Warning(this, null, null, Report.MALFORMED_DOCTYPE);
}
if (Options.XmlOut)
{
return true;
}
Node doctype = root.FindDocType();
if (Options.DocType == DocType.Omit)
{
if (doctype != null)
{
Node.DiscardElement(doctype);
}
return true;
}
if (Options.DocType == DocType.Strict)
{
Node.DiscardElement(doctype);
doctype = null;
guessed = HtmlVersion.Html40Strict;
}
else if (Options.DocType == DocType.Loose)
{
Node.DiscardElement(doctype);
doctype = null;
guessed = HtmlVersion.Html40Loose;
}
else if (Options.DocType == DocType.Auto)
{
if (doctype != null)
{
if (Doctype == HtmlVersion.Unknown)
{
return false;
}
switch (Doctype)
{
case HtmlVersion.Unknown:
return false;
case HtmlVersion.Html20:
if ((Versions & HtmlVersion.Html20) != 0)
{
return true;
}
break; /* to replace old version by new */
case HtmlVersion.Html32:
if ((Versions & HtmlVersion.Html32) != 0)
{
return true;
}
break; /* to replace old version by new */
case HtmlVersion.Html40Strict:
if ((Versions & HtmlVersion.Html40Strict) != 0)
{
return true;
}
break; /* to replace old version by new */
case HtmlVersion.Html40Loose:
if ((Versions & HtmlVersion.Html40Loose) != 0)
{
return true;
}
break; /* to replace old version by new */
case HtmlVersion.Frames:
if ((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();
}
if (guessed == HtmlVersion.Unknown)
{
return false;
}
//.........这里部分代码省略.........
示例2: SetXhtmlDocType
public virtual bool SetXhtmlDocType(Node root)
{
string fpi = " ";
string sysid = "";
const string namespaceRenamed = XHTML_NAMESPACE;
Node doctype = root.FindDocType();
if (Options.DocType == DocType.Omit)
{
if (doctype != null)
Node.DiscardElement(doctype);
return true;
}
if (Options.DocType == DocType.Auto)
{
/* see what flavor of XHTML this document matches */
if ((Versions & HtmlVersion.Html40Strict) != 0)
{
/* use XHTML strict */
fpi = "-//W3C//DTD XHTML 1.0 Strict//EN";
sysid = VOYAGER_STRICT;
}
else if ((Versions & HtmlVersion.Loose) != 0)
{
fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
sysid = VOYAGER_LOOSE;
}
else if ((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 == DocType.Strict)
{
fpi = "-//W3C//DTD XHTML 1.0 Strict//EN";
sysid = VOYAGER_STRICT;
}
else if (Options.DocType == DocType.Loose)
{
fpi = "-//W3C//DTD XHTML 1.0 Transitional//EN";
sysid = VOYAGER_LOOSE;
}
FixHtmlNameSpace(root, namespaceRenamed);
if (doctype == null)
{
doctype = NewNode(Node.DOC_TYPE_TAG, Lexbuf, 0, 0);
doctype.Next = root.Content;
doctype.Parent = root;
doctype.Prev = null;
root.Content = doctype;
}
if (Options.DocType == DocType.User && Options.DocTypeStr != null)
{
fpi = Options.DocTypeStr;
sysid = "";
}
Txtstart = Lexsize;
Txtend = 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("\"");
}
AddStringLiteral(sysid.Length + 6 >= Options.WrapLen ? "\n\"" : "\n \"");
/* add system identifier */
AddStringLiteral(sysid);
AddStringLiteral("\"");
Txtend = Lexsize;
doctype.Start = Txtstart;
doctype.End = Txtend;
return false;
//.........这里部分代码省略.........