예제 #1
0
        public static void TrimEmptyElement(Lexer lexer, Node element)
        {
            TagTable tt = lexer.Options.tt;

            if (lexer.CanPrune(element))
            {
                if (element.Type != TextNode)
                {
                    Report.Warning(lexer, element, null, Report.TRIM_EMPTY_ELEMENT);
                }

                DiscardElement(element);
            }
            else if (element.Tag == tt.TagP && element.Content == null)
            {
                /* replace <p></p> by <br><br> to preserve formatting */
                Node node = lexer.InferredTag("br");
                Node.CoerceNode(lexer, element, tt.TagBr);
                Node.InsertNodeAfterElement(element, node);
            }
        }