Verbeter de afhandeling van markdown-paragrafen

AI-generated summary

deeplow reports that Discourse does not follow CommonMark or GitHub Flavored Markdown specs regarding paragraph handling — specifically, consecutive lines like Foo\nbar render as separate lines instead of being joined into Foo bar, as the specs suggest. This causes issues for users replying via email clients (e.g., Thunderbird) that auto-wrap text, and for new users manually breaking lines. david clarifies this behavior is intentional and mirrors GitHub’s implementation, but admins can override it using the “traditional markdown linebreaks” setting. He also references a CommonMark discussion explaining the rationale. deeplow acknowledges the response and plans to review the linked topic.

According to the commonmark’s spec

Paragraph
A line ending is a newline (U+000A), a carriage return (U+000D) not followed by a newline, or a carriage return and a following newline.

Or Github Flavored Markdown spec

Paragraph
A sequence of non-blank lines that cannot be interpreted as other kinds of blocks forms a paragraph. The contents of the paragraph are the result of parsing the paragraph’s raw content as inlines. The paragraph’s raw content is formed by concatenating the lines and removing initial and final whitespace.

So,

Foo
bar

Should render as

Foo bar

But instead it renders as

Foo
bar

See the commonmark example or the Gihub’s one.

Is this a bug or intended diversion from the spec?

Use-case

This way of paragraph handling becomes particularly annoying when the some users reply by email, where many email clients (like thunderbird) create line breaks every so characters. Though from the design perspective, email users shouldn’t have to think about this nor change their email settings.

Here’s an example:

The only other situation I can think of where this would also happen is when new users start using discourse, sometimes they make make manual paragraphs this way.

3 likes

This is intentional, and follows the same behaviour as GitHub:

Admins can enable the “traditional markdown linebreaks” setting in the site settings to change the behaviour.

You may be interested in this topic which describes some of the rationale behind the implementation.

5 likes

Thanks a lot. I’ll read up on that

4 likes