HasOneChild() public method

public HasOneChild ( ) : bool
return bool
コード例 #1
0
ファイル: Clean.cs プロジェクト: r1pper/TidyNetPortable
        /*
        Replace implicit blockquote by div with an indent
        taking care to reduce nested blockquotes to a single
        div with the indent set to match the nesting depth
        */
        public virtual void Bq2Div(Node node)
        {
            while (node != null)
            {
                if (node.Tag == _tt.TagBlockquote && node.Isimplicit)
                {
                    int indent = 1;

                    while (node.HasOneChild() && node.Content.Tag == _tt.TagBlockquote && node.Isimplicit)
                    {
                        ++indent;
                        StripOnlyChild(node);
                    }

                    if (node.Content != null)
                    {
                        Bq2Div(node.Content);
                    }

                    string indentBuf = "margin-left: " + (2*indent).ToString() + "em";

                    node.Element = _tt.TagDiv.Name;
                    node.Tag = _tt.TagDiv;
                    node.AddAttribute("style", indentBuf);
                }
                else if (node.Content != null)
                {
                    Bq2Div(node.Content);
                }

                node = node.Next;
            }
        }
コード例 #2
0
ファイル: Clean.cs プロジェクト: r1pper/TidyNetPortable
        /*
        Some people use dir or ul without an li
        to indent the content. The pattern to
        look for is a list with a single implicit
        li. This is recursively replaced by an
        implicit blockquote.
        */
        public virtual void List2Bq(Node node)
        {
            while (node != null)
            {
                if (node.Content != null)
                {
                    List2Bq(node.Content);
                }

                if (node.Tag != null && node.Tag.Parser == ParserImpl.ParseList && node.HasOneChild() &&
                    node.Content.Isimplicit)
                {
                    StripOnlyChild(node);
                    node.Element = _tt.TagBlockquote.Name;
                    node.Tag = _tt.TagBlockquote;
                    node.Isimplicit = true;
                }

                node = node.Next;
            }
        }