dart-lang / markdown

A Dart markdown library
https://pub.dev/packages/markdown
BSD 3-Clause "New" or "Revised" License
443 stars 202 forks source link

[Feature] Keep subsequent newlines "\n" intact #437

Closed Cellaryllis closed 2 years ago

Cellaryllis commented 2 years ago

Hello,

We're wondering if it's possible to add support for keeping newlines intact? We appreciate being able to use markdown, however at some points it's really useful to be able to add multiple newlines and be able to space out content of the markdown renderer in the user-input text.

We tried to hack it with replacing all "\n" with " \" (Em Space and newline), but this breaks some of the other markdown elements such as "---" and some image links. So that doesn't seem to be an optimal solution.

Is there any way we can preserve multiple newlines below each other, without breaking any of the other markdown elements?

Example:

Hello\n\n\n\nWorld

Resulting in

Hello

World
srawlins commented 2 years ago

The markdown package aims to conform to the CommonMark standard of markdown rendering.

I don't think I see a way in CommonMark markdown to render multiple hard line breaks, except with HTML tags. For example:

a
<br />
<br />
<br />
b

renders as:

<p>a
<br />
<br />
<br />
b</p>

Does that work?

Cellaryllis commented 2 years ago

Hey there! Thanks for the answer. I think that would work yes!