parsedown
parsedown copied to clipboard
feature request option for \n => <br />
I realize that to get a line break in markdown you end the line with two spaces..
Some flavors of markdown don't require two-spaces and automatically convert \n to <br />
(ie this very comment box on github doesn't require two spaces for a line break)
Can this be an option?
Does ->setBreaksEnabled(true) give the functionality you're after (it's not exactly \n -> <br> but it aims to replicate GitHub's behaviour).
It does not. :( But I must admit I didn't know about that method... guilty of not looking at the source.
This seems to work pretty well
$html = \preg_replace(
'#(?:<br />\n)?<br />(</\w+>)#',
'$1',
\preg_replace('#^(.+)\n#m', '$1<br />'."\n", $markdown) // a more selective nl2br
);
支持,打四个空格太麻烦了