commonmark/commonmark-spec

Multi line break fail

Closed this issue · 5 comments

## COMMON_STEPS
* test 1
\
\
\
* test 2
* test 3

produces
image

<li><p>test 1
<br />
<br />
\</p></li>
<li><p>test 2</p></li>
<li><p>test 3</p></li>

not 3 line breaks

https://spec.commonmark.org/dingus/?text=%23%23%20COMMON_STEPS%0A*%20test%201%0A%5C%0A%5C%0A%5C%0A*%20test%202%0A*%20test%203

Why make life harder? Simply allow any line breaks.

I think you misunderstand the semantics of \ to be "insert a <br> tag here", which it is not, per the spec:

A line break (not in a code span or HTML tag) that is preceded by two or more spaces and does not occur at the end of a block is parsed as a hard line break (rendered in HTML as a
tag)

and more specifically:

Hard line breaks are for separating inline content within a block. Neither syntax for hard line breaks works at the end of a paragraph or other block element

That said, Pandoc behaves the way you want, whether intentionally or by accident, I don't know.

I've found the suggestion on stackoverflow, but looks like it's only working with <10% of parsers.
Looks like the universal solution is <br> which is not as practical.

The most intuitive would be to just parse new lines as breaks.

The semantics of HTML is also that <br> is only sensical inside paragraphs, not at the end. The user on SO you are following is wrong.

So how do you recommend inserting 5 new lines in the output? Surely a markdown language would cover that.

Don't; because it's not a good idea.

HTML has meaning. Markdown is for generating those things with meaning too. It's not supposed to do things without meaning.

You can still abuse HTML. And CM allows that too: you can write those br tags (even though you shouldn't) in markdown.