줄바꿈이 포함된 HTML 제목 -> 제목이 표시되지 않으며 미리보기와 렌더링된 게시글 간 불일치

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:


Heading test with line breaks

Normal paragraph.

Heading with no line breaks


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.

2개의 좋아요

Hmm given the ltr stuff there @Osama could this be related to the CSS flipper we recently added?

2개의 좋아요

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).

6개의 좋아요

This seems to happen during cooking, specifically markdown parsing.

Passing a header with linebreaks to PrettyText.markdown returns with the content of header wrapped in a p tag.

And then during scrubbing, the paragraph get’s extracted out out of the header tag resulting in the following:

I suppose this happens since a paragraph in a header tag isn’t spec compliant?

I’m still reviewing the markdown parser code to figure out why the content is being wrapped in p tag in the first place.

2개의 좋아요

Oh this is very related to:

I am OK to wait a few more weeks for Loofah to release

Will shoot out a Tweet to Mike to mention this popped up.

2개의 좋아요

Hi there, thanks for looking into this. HTML doesn’t care about line breaks, so technically this is correct:

<h2>

Heading test with line breaks

</h2>

It simply seems to be a problem of the Markdown parser running after/inside the HTML parser, which is generating <p> tags for the line returns.

1개의 좋아요

Hey there, we’ve fixed this with

https://github.com/discourse/discourse/pull/21522

as seen here:

Heading test with line breaks

Normal paragraph.

Heading with no line breaks


8개의 좋아요

Glad to hear, thanks @nat! Does this require rebaking posts?

2개의 좋아요

Yes, it does require a rebake — we can’t do it for you automatically with this fix since it’s an expensive operation.

3개의 좋아요

This topic was automatically closed after 2 days. New replies are no longer allowed.