cavalist
cavalist

Reputation: 125

Why markdown ignores single line break?

I know the solution to make single line break. I just want to know the reason.

when I input this,

line1
line2

preview of this md file is

line1line2

Why? is single line break looking bad or what?

Upvotes: 3

Views: 3312

Answers (2)

Waylan
Waylan

Reputation: 42487

@Chris's answer provides the reasons mentioned in the documentation. However, to understand why those decisions were made, we need to consider the situation at the time. Text editors have changed and become much more sophisticated since Markdown was created. As an example, note the documentation (PDF) for BBEdit, the text editor which is a favorite of the creator of Markdown (as I understand it, he actually worked for the company as a software developer before creating Markdown).

At the bottom of page 110 of the documentation, we find this note:

Users of very old versions of BBEdit or BBEdit Lite will note that the Wrap while Typing option (which hard-wrapped text automatically by inserting a Return when you reach the right margin) has been relegated to the dustbin of history. It has been superseded by soft wrapping.

Back when Markdown was created, text editors did not offer soft wrapping as a feature. Instead, they simulated soft wrapping by "automatically" inserting hard line breaks. Less sophisticated editors actually required users to manually insert the heard lines breaks and offered no soft wrapping at all. Therefore, if Markdown were to preserve those hard line breaks, it would result in something different from what was intended by the document author.

Markdown was simply never updated to match current common behaviors of text editors. In fact, some users still prefer that way of working and still customize their text editors to work that way. They still get to enjoy the same behavior of Markdown.

By the way, I suggest reading through the 5 or so pages of BBEdit's manual explaining all of the text wrapping options. There are a lot of different ways of working and we should never assume that all people work the same way as we do. If only every text editor offered such a rich set of text wrapping features.

Upvotes: 3

Chris
Chris

Reputation: 136889

So the Markdown source, which is intended to be as readable as possible, can be nicely formatted.

Quoting the documentation:

Yes, this takes a tad more effort to create a <br />, but a simplistic "every line break is a <br />" rule wouldn’t work for Markdown. Markdown’s email-style blockquoting and multi-paragraph list items work best — and look better — when you format them with hard breaks.

Note that you can force a line break (<br>) if you end your line1 with two or more spaces:

line1
line2

A blank line actually creates a new paragraph.

Upvotes: 3

Related Questions