Skip to content

Extra <p> around <div> in HTML output #75

Description

@melisgl

I'm trying to wrap a div around some Markdown and its HTML rendering with CSS, but the opening tag gets wrapped in a p, making it ineffective. Here is a small test case without any Markdown:

(with-output-to-string (out)
  (3bmd::print-doc-to-stream-using-format
   (3bmd-grammar:parse-doc (format nil "<div>~%~%</div>"))
   out :html))
=> "<p><div></p>
</div>
"

I'd expect the output to be <div></div> with two newlines in between them.
Similarly:

(with-output-to-string (out)
  (3bmd::print-doc-to-stream-using-format
   (3bmd-grammar:parse-doc (format nil "<div>~%~%- x~%- y~%~%</div>"))
   out :html))
=> "<p><div></p>

<ul>
<li>x</li>
<li>y</li>
</ul>
</div>
"

If I add a newlines after the closing tag, the Markdown inside is not processed:

(with-output-to-string (out)
  (3bmd::print-doc-to-stream-using-format
   (3bmd-grammar:parse-doc (format nil "<div>~%~%- x~%- y~%~%</div>~%"))
   out :html))
=> "<div>

- x
- y

</div>
"

For some reason, adding a space in front of the opening and closing tags unwraps the closing div:

(with-output-to-string (out)
  (3bmd::print-doc-to-stream-using-format
   (3bmd-grammar:parse-doc (format nil " <div>~%~%- x~%- y~%~% </div>~%"))
   out :html))
=> "<p><div></p>

<ul>
<li>x</li>
<li>y</li>
</ul>
 </div>
"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions