Exemplo n.º 1
0
        /// <summary>
        /// Parses the document
        /// </summary>
        private void ParseDocument()
        {
            InitialContainer root   = this;
            MatchCollection  tags   = Parser.Match(Parser.HtmlTag, DocumentSource);
            CssBox           curBox = root;
            int lastEnd             = -1;

            foreach (Match tagmatch in tags)
            {
                string text = tagmatch.Index > 0 ? DocumentSource.Substring(lastEnd + 1, tagmatch.Index - lastEnd - 1) : string.Empty;

                if (!string.IsNullOrEmpty(text.Trim()))
                {
                    CssAnonymousBox abox = new CssAnonymousBox(curBox)
                    {
                        Text = text
                    };
                }
                else if (text != null && text.Length > 0)
                {
                    CssAnonymousSpaceBox sbox = new CssAnonymousSpaceBox(curBox)
                    {
                        Text = text
                    };
                }

                HtmlTag tag = new HtmlTag(tagmatch.Value);

                if (tag.IsClosing)
                {
                    curBox = FindParent(tag.TagName, curBox);
                }
                else if (tag.IsSingle)
                {
                    CssBox foo = new CssBox(curBox, tag);
                }
                else
                {
                    curBox = new CssBox(curBox, tag);
                }



                lastEnd = tagmatch.Index + tagmatch.Length - 1;
            }

            string finaltext = DocumentSource.Substring((lastEnd > 0 ? lastEnd + 1 : 0), DocumentSource.Length - lastEnd - 1 + (lastEnd == 0 ? 1 : 0));

            if (!string.IsNullOrEmpty(finaltext))
            {
                CssAnonymousBox abox = new CssAnonymousBox(curBox)
                {
                    Text = finaltext
                };
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Parses the document
        /// </summary>
        private void ParseDocument()
        {
            var    root    = this;
            var    tags    = Parser.Match(Parser.HtmlTag, DocumentSource);
            CssBox curBox  = root;
            var    lastEnd = -1;

            foreach (Match tagmatch in tags)
            {
                var text = tagmatch.Index > 0
                    ? DocumentSource.Substring(lastEnd + 1, tagmatch.Index - lastEnd - 1)
                    : string.Empty;

                if (!string.IsNullOrEmpty(text.Trim()))
                {
                    var abox = new CssAnonymousBox(curBox);
                    abox.Text = text;
                }
                else if (text != null && text.Length > 0)
                {
                    var sbox = new CssAnonymousSpaceBox(curBox);
                    sbox.Text = text;
                }

                var tag = new HtmlTag(tagmatch.Value);

                if (tag.IsClosing)
                {
                    curBox = FindParent(tag.TagName, curBox);
                }
                else if (tag.IsSingle)
                {
                    var foo = new CssBox(curBox, tag);
                }
                else
                {
                    curBox = new CssBox(curBox, tag);
                }


                lastEnd = tagmatch.Index + tagmatch.Length - 1;
            }

            var finaltext = DocumentSource.Substring(lastEnd > 0 ? lastEnd + 1 : 0,
                                                     DocumentSource.Length - lastEnd - 1 + (lastEnd == 0 ? 1 : 0));

            if (!string.IsNullOrEmpty(finaltext))
            {
                var abox = new CssAnonymousBox(curBox);
                abox.Text = finaltext;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the document
        /// </summary>
        private void ParseDocument()
        {
            InitialContainer root = this;
            MatchCollection tags = Parser.Match(Parser.HtmlTag, DocumentSource);
            CssBox curBox = root;
            int lastEnd = -1;

            foreach (Match tagmatch in tags)
            {
                string text = tagmatch.Index > 0 ? DocumentSource.Substring(lastEnd + 1, tagmatch.Index - lastEnd - 1) : string.Empty;

                if (!string.IsNullOrEmpty(text.Trim()))
                {
                    CssAnonymousBox abox = new CssAnonymousBox(curBox);
                    abox.Text = text;
                }
                else if(text != null && text.Length > 0)
                {
                    CssAnonymousSpaceBox sbox = new CssAnonymousSpaceBox(curBox);
                    sbox.Text = text;
                }

                HtmlTag tag = new HtmlTag(tagmatch.Value);

                if (tag.IsClosing)
                {
                    curBox = FindParent(tag.TagName, curBox);
                }
                else if(tag.IsSingle)
                {
                    CssBox foo = new CssBox(curBox, tag);
                }
                else
                {
                    curBox = new CssBox(curBox, tag);
                }

                lastEnd = tagmatch.Index + tagmatch.Length - 1;
            }

            string finaltext = DocumentSource.Substring((lastEnd > 0 ? lastEnd + 1 : 0), DocumentSource.Length - lastEnd - 1 + (lastEnd == 0 ? 1 : 0)) ;

            if (!string.IsNullOrEmpty(finaltext))
            {
                CssAnonymousBox abox = new CssAnonymousBox(curBox);
                abox.Text = finaltext;
            }
        }