예제 #1
0
        /// <summary>
        /// Parses an <see cref="HtmlTag"/> from the input and
        /// returns it.
        /// </summary>
        private HtmlTag GetTag()
        {
            // Handle comment
            if (tp.Peek(1) == '!' && tp.Peek(2) == '-' && tp.Peek(3) == '-')
            {
                SkipToEndOfComment();
                return(null);
            }

            // Handle DOCTYPE or other <! ... >
            if (tp.Peek(1) == '!')
            {
                SkipToEndOfTag(true);
                return(null);
            }

            var startPos = tp.Position;
            var htmlTag  = new HtmlTag();

            if (htmlTag.Parse(tp))
            {
                return(htmlTag);
            }

            // Handle invalid tags
            tp.MoveTo(startPos + 1);
            xml.Append("&lt;");
            return(null);
        }