예제 #1
0
        /// <summary>
        /// Internal static function that validates a markup document object as being a valid HTML document.
        /// </summary>
        /// <param name="document">The document to examine.</param>
        /// <returns>True to false to indicate validity.</returns>
        private static bool ValidateAsHTML(MarkupDocument document)
        {
            bool valid = false;

            valid = document["html"].Length == 1;                     // should only be 1 HTML tag
            valid = valid && document["html"][0]["head"].Length < 2;  // can be 0 or 1 HEAD tag
            valid = valid && document["html"][0]["body"].Length == 1; // should only be 1 BODY tag
            return(valid);
        }
예제 #2
0
        /// <summary>
        /// This is the only constructor for this class.
        /// </summary>
        /// <param name="document">The owning MarkupDocument object.</param>
        /// <param name="tagIndexBegin">The index in the document text at which this tag begins.</param>
        /// <param name="tagLength">The text length of this tag.</param>
        /// <param name="tagNameIndexBegin">The index in the document text at which the name of this tag begins.</param>
        /// <param name="tagNameLength">The text length of the name of this tag.</param>
        internal MarkupTag(MarkupDocument document, int tagIndexBegin, int tagLength, int tagNameIndexBegin, int tagNameLength)
        {
            this.document          = document;
            this.tagIndexBegin     = tagIndexBegin;
            this.tagLength         = tagLength;
            this.tagNameIndexBegin = tagNameIndexBegin;
            this.tagNameLength     = tagNameLength;
            string text = this.Text.Trim();

            inline  = text.EndsWith(INLINE_ENDSWITH_TEXT) || MarkupDocument.IsKnownInlineTag(Tag, document.StringComparison);
            comment = text.StartsWith(COMMENT_BEGINS_WITH_TEXT);
            ParseAttributes();
        }