When allowing all types or specifically 'break' in v3, it will not add BR breaks. This also does not work in the demo which allows all types.
I expected the same behaviour as 'SoftBreak' in v2 (although the naming is confusing...), where single enters end up as a BR and multiple end up as P. The 'SoftBreak' features seems to have been removed however.
It follows the "spec" in this regard; a hard break needs two or more spaces as the end of a line, followed by a newline character. If you want it to insert a break for each newline character, you can do that through a plugin. I've just released v3.0.1 with _experimental_ plugin support.
So in your case, you could install remark-breaks and do the following:
const React = require('react')
const ReactDOM = require('react-dom')
const Markdown = require('react-markdown')
const breaks = require('remark-breaks')
const input = `break
me
at
every
line`
ReactDOM.render(
<Markdown source={input} plugins={[breaks]} />,
document.getElementById('root')
)
Which would output something along the lines of:
<p>break<br />me<br />at<br />every<br />line</p>
Just for your information, the newline character which appears in the very beginning of content, does not render <br />.
I had to append a space to make it work.
Not sure if this one is fixable:
const Markdown = require('react-markdown')
const breaks = require('remark-breaks')
<Markdown source="# Hello\nWorld\n!" plugins={[breaks]} />
Renders:
<h1>Hello</h1>
<p>World<br />!</p>
Most helpful comment
It follows the "spec" in this regard; a hard break needs two or more spaces as the end of a line, followed by a newline character. If you want it to insert a break for each newline character, you can do that through a plugin. I've just released v3.0.1 with _experimental_ plugin support.
So in your case, you could install remark-breaks and do the following:
Which would output something along the lines of: