A bug was reported where HTML headings containing line breaks are not rendered correctly in baked posts on Discourse, despite appearing fine in previews. The issue causes the heading tag to be left empty and the text wrapped in a <p> tag instead, e.g., <h2></h2><p>Heading test with line breaks</p>rahim123. Initial suspicion pointed to the CSS flipper, but Osama ruled it out, confirming the problem lies in post cooking. Selase traced it to the Markdown parser (PrettyText.markdown) wrapping header content in <p> tags during parsing, which then get extracted during scrubbing — likely because paragraphs inside headers aren’t HTML spec-compliant. Sam linked this to a similar issue and noted it may require waiting for a Loofah update. rahim123 clarified that HTML itself allows line breaks in headings, so the issue stems from Markdown processing after HTML parsing. The bug was fixed in PR #21522 by nat, restoring correct rendering. However, existing posts must be manually rebaked to reflect the fix, as automatic rebaking is too resource-intensive nat.
Hi there, I have some posts imported from another forum software with line breaks in headings. These are shown correctly in the post preview, but they are not rendered as headings in the final baked post. I’m seeing this issue on my forum updated yesterday and also here on Discourse Meta:
It’s leaving the <h2> blank and is wrapping the text after that in <p> :
<h2 dir="ltr">
</h2><p dir="ltr">Heading test with line breaks</p>
I’m 99% sure that this is a recent regression, as I specifically checked headings in imported posts from the same user during the migration process, and the user and I both remember that they were rendered correctly.
I don’t think so because the final/cooked HTML of the post is wrong and the CSS flipper (whether the old or the new one) isn’t involved at all in the post cooking process.
^ the text inside the <p> should be inside the <h2> and there should be no <p> at all (I think).