wordpress/php markdown hard line breaks

Markdown is cool in general but doing a <br /> is PITA

According to the syntax you have to

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.
Yes, this takes a tad more effort to create a <br />, but a simplistic "every line break is a <br />" rule wouldn’t work for Markdown. Markdown’s email-style blockquoting and multi-paragraph list items work best — and look better — when you format them with hard breaks.

But I really want a <br /> whenever I press enter in wordpress. Especially copy a lot of text from elsewhere or quoting some text.

I am using Markdown for WordPress and bbPress on this blog, I tried to convince the author to add an option for enter-as-<br />, the author seems reluctant to do it

So let's DIY, open /wp-content/plugins/markdown-for-wordpress-and-bbpress/markdown.php, line 702

change

function doHardBreaks($text) {
                # Do hard breaks:
                return preg_replace_callback('/ {2,}\n/',

to

function doHardBreaks($text) {
                # Do hard breaks:
                return preg_replace_callback('/\n/',

Done.

Comments