Example #1
0
        /// <summary>Called when a close tag of this element has
        /// been created and is being added to the given lexer.</summary>
        /// <returns>True if this element handled itself.</returns>
        public override bool OnLexerCloseNode(HtmlLexer lexer, int mode)
        {
            if ((mode & IgnoreClose) != 0)
            {
                // Just ignore it/ do nothing.
            }
            else if (mode == HtmlTreeMode.AfterBody)
            {
                // After after body:
                lexer.CurrentMode = HtmlTreeMode.AfterAfterBody;
            }
            else if (mode == HtmlTreeMode.InHead)
            {
                // Use anything else method:
                lexer.InHeadElse(null, "html");
            }
            else if (mode == HtmlTreeMode.BeforeHtml)
            {
                // Allowed to fall through the 'anything else' case:
                lexer.BeforeHtmlElse(null, "html");
            }
            else if (mode == HtmlTreeMode.AfterHead)
            {
                // Use anything else method:
                lexer.AfterHeadElse(null, "html");
            }
            else if (mode == HtmlTreeMode.InBody)
            {
                // Check if the stack contains elements that aren't allowed to still be open:
                lexer.CheckAfterBodyStack();

                // Ok! (It throws a fatal error otherwise)
                // Change to after body and reprocess:
                lexer.CurrentMode = HtmlTreeMode.AfterBody;
                lexer.Process(null, "html");
            }
            else if (mode == HtmlTreeMode.AfterFrameset)
            {
                // After after frameset:
                lexer.CurrentMode = HtmlTreeMode.AfterAfterFrameset;
            }
            else
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>Called when a close tag of this element has
        /// been created and is being added to the given lexer.</summary>
        /// <returns>True if this element handled itself.</returns>
        public override bool OnLexerCloseNode(HtmlLexer lexer, int mode)
        {
            if (mode == HtmlTreeMode.InBody)
            {
                // Check if the stack contains elements that aren't allowed to still be open:
                lexer.CheckAfterBodyStack();

                // Ok! (It throws a fatal error otherwise)
                // Note that the spec doesn't actually tell us to close the body element.
                // Just change to after body:
                lexer.CurrentMode = HtmlTreeMode.AfterBody;
            }
            else if (mode == HtmlTreeMode.InHead)
            {
                // Use anything else method:
                lexer.InHeadElse(null, "body");
            }
            else if (mode == HtmlTreeMode.AfterHead)
            {
                // Use anything else method:
                lexer.AfterHeadElse(null, "body");
            }
            else if (mode == HtmlTreeMode.BeforeHtml)
            {
                // Allowed to fall through the 'anything else' case:
                lexer.BeforeHtmlElse(null, "body");
            }
            else if ((mode & IgnoreClose) != 0)
            {
                // Just ignore it/ do nothing.
            }
            else
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        /// <summary>Called when a close tag of this element has
        /// been created and is being added to the given lexer.</summary>
        /// <returns>True if this element handled itself.</returns>
        public override bool OnLexerCloseNode(HtmlLexer lexer, int mode)
        {
            if (mode == HtmlTreeMode.InBody)
            {
                // Acts like a self-closed open node:
                Element el = lexer.CreateTag("br", true);
                lexer.Push(el, false);
            }
            else if (mode == HtmlTreeMode.BeforeHtml)
            {
                // Allowed to fall through the 'anything else' case:
                lexer.BeforeHtmlElse(null, "br");
            }
            else if (mode == HtmlTreeMode.InHead)
            {
                // Use anything else method:
                lexer.InHeadElse(null, "br");
            }
            else if (mode == HtmlTreeMode.AfterHead)
            {
                // Use anything else method:
                lexer.AfterHeadElse(null, "br");
            }
            else if (mode == HtmlTreeMode.InHeadNoScript)
            {
                // Reprocess as in head:
                lexer.CurrentMode = HtmlTreeMode.InHead;
                lexer.Process(null, "br");
            }
            else
            {
                return(false);
            }

            return(true);
        }