Marked: Linebreaks doesn't work correctly

Created on 25 Oct 2018  路  3Comments  路  Source: markedjs/marked

Hi, if I write:

test1test2
test3test4

Will be rendered as:

<p>test1test2
test3test4</p>

For work correctly I need to add two spaces like:

test1test2

test3test4

That becomes:

<p>test1test2</p>
<p>test3test4</p>

What is wrong? I've used in Vue:
marked(Text);

question

Most helpful comment

If you set the breaks and gfm options to true it will add a <br> on every line break

marked("test1test2" + "\n" + "test3test4", {breaks: true, gfm: true});
// <p>test1test2<br>test3test4</p>

demo

All 3 comments

That is the way the spec defines a paragraph

https://spec.commonmark.org/0.28/#example-183

https://github.github.com/gfm/#example-183

Thank you, but I see other markdown editors that treat every line as a new paragraph.
What specs do I need to use to archive this?
It's possible with this package?

If you set the breaks and gfm options to true it will add a <br> on every line break

marked("test1test2" + "\n" + "test3test4", {breaks: true, gfm: true});
// <p>test1test2<br>test3test4</p>

demo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camwiegert picture camwiegert  路  4Comments

chunhei2008 picture chunhei2008  路  3Comments

bennycode picture bennycode  路  4Comments

raguay picture raguay  路  4Comments

amejiarosario picture amejiarosario  路  3Comments