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


C# Node.FindHead方法代码示例

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


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

示例1: CreateStyleElement

        /* create style element using rules from dictionary */
        private void CreateStyleElement(Lexer lexer, Node doc)
        {
            Style style;

            if (lexer.Styles == null && NiceBody(lexer, doc))
            {
                return;
            }

            Node node = lexer.NewNode(Node.START_TAG, null, 0, 0, "style");
            node.Isimplicit = true;

            /* insert type attribute */
            var av = new AttVal(null, null, '"', "type", "text/css");
            av.Dict = AttributeTable.DefaultAttributeTable.FindAttribute(av);
            node.Attributes = av;

            Node body = doc.FindBody(lexer.Options.TagTable);

            lexer.Txtstart = lexer.Lexsize;

            if (body != null)
            {
                CleanBodyAttrs(lexer, body);
            }

            for (style = lexer.Styles; style != null; style = style.Next)
            {
                lexer.AddCharToLexer(' ');
                lexer.AddStringLiteral(style.Tag);
                lexer.AddCharToLexer('.');
                lexer.AddStringLiteral(style.TagClass);
                lexer.AddCharToLexer(' ');
                lexer.AddCharToLexer('{');
                lexer.AddStringLiteral(style.Properties);
                lexer.AddCharToLexer('}');
                lexer.AddCharToLexer('\n');
            }

            lexer.Txtend = lexer.Lexsize;

            Node.InsertNodeAtEnd(node, lexer.NewNode(Node.TEXT_NODE, lexer.Lexbuf, lexer.Txtstart, lexer.Txtend));

            /*
            now insert style element into document head

            doc is root node. search its children for html node
            the head node should be first child of html node
            */

            Node head = doc.FindHead(lexer.Options.TagTable);

            if (head != null)
            {
                Node.InsertNodeAtEnd(head, node);
            }
        }
开发者ID:r1pper,项目名称:TidyNetPortable,代码行数:58,代码来源:Clean.cs

示例2: AddTransitionEffect

        /*
        Add meta element for page transition effect, this works on IE but not NS
        */
        public virtual void AddTransitionEffect(Lexer lexer, Node root, short effect, double duration)
        {
            Node head = root.FindHead(lexer.Options.TagTable);
            string transition;

            if (0 <= effect && effect <= 23)
            {
                transition = "revealTrans(Duration=" + (duration).ToString() + ",Transition=" + effect + ")";
            }
            else
            {
                transition = "blendTrans(Duration=" + (duration).ToString() + ")";
            }

            if (head != null)
            {
                Node meta = lexer.InferredTag("meta");
                meta.AddAttribute("http-equiv", "Page-Enter");
                meta.AddAttribute("content", transition);
                Node.InsertNodeAtStart(head, meta);
            }
        }
开发者ID:r1pper,项目名称:TidyNetPortable,代码行数:25,代码来源:PPrint.cs

示例3: AddGenerator

        /* add meta element for Tidy */
        public virtual bool AddGenerator(Node root)
        {
            Node head = root.FindHead(Options.TagTable);

            if (head != null)
            {
                Node node;
                for (node = head.Content; node != null; node = node.Next)
                {
                    if (node.Tag == Options.TagTable.TagMeta)
                    {
                        AttVal attval = node.GetAttrByName("name");

                        if (attval != null && attval.Val != null && String.CompareOrdinal(attval.Val, "generator") == 0)
                        {
                            attval = node.GetAttrByName("content");

                            if (attval != null && attval.Val != null && attval.Val.Length >= 9 &&
                                String.CompareOrdinal(attval.Val.Substring(0, 9), "HTML Tidy") == 0)
                            {
                                return false;
                            }
                        }
                    }
                }

                node = InferredTag("meta");
                node.AddAttribute("content", "HTML Tidy, see www.w3.org");
                node.AddAttribute("name", "generator");
                Node.InsertNodeAtStart(head, node);
                return true;
            }

            return false;
        }
开发者ID:r1pper,项目名称:TidyNetPortable,代码行数:36,代码来源:Lexer.cs


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