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


C# Node.FindDocType方法代码示例

本文整理汇总了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;
            }
//.........这里部分代码省略.........
开发者ID:r1pper,项目名称:TidyNetPortable,代码行数:101,代码来源:Lexer.cs

示例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;
//.........这里部分代码省略.........
开发者ID:r1pper,项目名称:TidyNetPortable,代码行数:101,代码来源:Lexer.cs


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