JsonFx.BuildTools.HtmlDistiller.HtmlDistiller.ParseBlock C# (CSharp) Method

ParseBlock() private method

Parses for "unparsed blocks" (e.g. comments, code blocks)
This supports comments, DocType declarations, CDATA sections, and ASP/JSP-style blocks.
private ParseBlock ( string startDelim, string endDelim ) : HtmlTag
startDelim string
endDelim string
return HtmlTag
        private HtmlTag ParseBlock(string startDelim, string endDelim)
        {
            int i=0;
            for (i=0; i<startDelim.Length; i++)
            {
                if (this.Peek(i) != startDelim[i])
                {
                    return null;
                }
            }

            // consume LessThan
            this.EmptyBuffer(1);

            string blockName = this.FlushBuffer(startDelim.Length-1);

            i = 0;
            while (!this.IsEOF)
            {
                if (this.Peek(i) == endDelim[i])
                {
                    i++;
                    if (i == endDelim.Length)
                    {
                        break;
                    }
                }
                else
                {
                    i = 0;

                    // add to comment contents
                    this.Advance();
                }
            }

            this.ParseSyncPoint();

            string content = this.FlushBuffer();
            if (!this.IsEOF)
            {
                this.EmptyBuffer(endDelim.Length);
            }

            HtmlTag unparsed = new HtmlTag(blockName, this.htmlFilter);
            if (!String.IsNullOrEmpty(content))
            {
                unparsed.Content = content;
            }
            unparsed.EndDelim = endDelim.Substring(0, endDelim.Length-1);

            return unparsed;
        }