evilstreak / markdown-js

A Markdown parser for javascript
7.7k stars 863 forks source link

Line break not working #28

Closed eric-wieser closed 12 years ago

eric-wieser commented 13 years ago

The following:

This is a  
line break

Is not being correctly output as

This is a
line break

Instead, two line breaks are inserted. See http://jsfiddle.net/bgwDK/

eric-wieser commented 13 years ago

Github is behaving incorrectly as well. From the Markdown Documentation

When you do want to insert a
break tag using Markdown, you end a line with two or more spaces, then type return.

Your code is inserting <br></br> when it should be inserting <br />

franzwilding commented 12 years ago

i solved it for myself a little dirty, maybe a hint for someone else:

1314: // be careful about adding whitespace here for inline elements
1315: if(tag == "br")
1316:   return "<"+ tag + tag_attrs + "/>";
1317: else
1318:   return "<"+ tag + tag_attrs + ">" + content.join( "" ) + "</" + tag + ">";
danlec commented 12 years ago

I've observed this problem as well and fixed it with a patch similar to franzwilding's

franzwilding commented 12 years ago

good to hear!

thank you!