markedjs / marked

A markdown parser and compiler. Built for speed.
https://marked.js.org
Other
32.51k stars 3.38k forks source link

New Lines Not Recognized/Supported #81

Closed joemccann closed 11 years ago

joemccann commented 11 years ago

If you copy paste the following in and run marked(theTextBelow):

Bacon ipsum dolor sit amet pastrami strip steak pancetta capicola pig t-bone corned beef filet mignon tenderloin ham hock hamburger bresaola swine tri-tip. Cow turducken jowl prosciutto. Venison meatloaf jowl salami frankfurter, tri-tip swine. 

Kielbasa spare ribs bacon jerky leberkas capicola filet mignon turkey pork shoulder rump short loin prosciutto. Tongue jerky jowl frankfurter shoulder leberkas salami pork belly flank pork kielbasa pork chop corned beef. Shankle short loin tail bacon ball tip t-bone frankfurter venison.

Frankfurter pork chop jerky capicola brisket, ribeye pork pastrami bacon. Meatloaf brisket venison chicken leberkas turducken shoulder jerky sirloin boudin. Turducken ribeye turkey pork boudin sausage. Cow frankfurter shankle shank boudin. 

It creates on huge paragraph as opposed to 3 separate paragraphs.

I'm trying to use Marked for dillinger.io, but this is a deal breaker. :/

chjj commented 11 years ago
$ marked
Bacon ipsum dolor sit amet pastrami strip steak pancetta capicola pig t-bone corned beef filet mignon tenderloin
 ham hock hamburger bresaola swine tri-tip. Cow turducken jowl prosciutto. Venison meatloaf jowl salami frankfur
ter, tri-tip swine. 

Kielbasa spare ribs bacon jerky leberkas capicola filet mignon turkey pork shoulder rump short loin prosciutto. 
Tongue jerky jowl frankfurter shoulder leberkas salami pork belly flank pork kielbasa pork chop corned beef. Sha
nkle short loin tail bacon ball tip t-bone frankfurter venison.

Frankfurter pork chop jerky capicola brisket, ribeye pork pastrami bacon. Meatloaf brisket venison chicken leber
kas turducken shoulder jerky sirloin boudin. Turducken ribeye turkey pork boudin sausage. Cow frankfurter shankl
e shank boudin. 
^D
<p>Bacon ipsum dolor sit amet pastrami strip steak pancetta capicola pig t-bone corned beef filet mignon tenderl
oin ham hock hamburger bresaola swine tri-tip. Cow turducken jowl prosciutto. Venison meatloaf jowl salami frank
furter, tri-tip swine. 

</p>
<p>Kielbasa spare ribs bacon jerky leberkas capicola filet mignon turkey pork shoulder rump short loin prosciutt
o. Tongue jerky jowl frankfurter shoulder leberkas salami pork belly flank pork kielbasa pork chop corned beef. 
Shankle short loin tail bacon ball tip t-bone frankfurter venison.

</p>
<p>Frankfurter pork chop jerky capicola brisket, ribeye pork pastrami bacon. Meatloaf brisket venison chicken le
berkas turducken shoulder jerky sirloin boudin. Turducken ribeye turkey pork boudin sausage. Cow frankfurter sha
nkle shank boudin. 
</p>

I don't see a problem. If a problem with something so essential existed, there would probably be multiple test failures. Marked is passing every test it should.

I'm guessing you're having the problem mentioned in #52, where sometimes contenteditable elements and other things will replace SP, LF, or CRLF with \u00a0 or something else weird like the unicode NL character. This is really the browsers fault, but I should probably land the fix for this because a lot of people seem unaware of this quirk.

joemccann commented 11 years ago

Yeah would be great. Would love to move over to Marked for Dillinger.io

paulmillr commented 11 years ago

GFM bug:

A
B
C

on github gives:

A B C

when in marked it gives one line with three spaces

yyfearth commented 11 years ago

but in GFM, it designed to be use new line directly instead of use spaces in one line, i think it is not a bug

http://github.github.com/github-flavored-markdown/:

Differences from traditional Markdown

Newlines

The biggest difference that GFM introduces is in the handling of linebreaks. With SM you can hard wrap paragraphs of text and they will be combined into a single paragraph. We find this to be the cause of a huge number of unintentional formatting errors. GFM treats newlines in paragraph-like content as real line breaks, which is probably what you intended.

so i think in marked, when i use gfm: true, it should be follow gfm style

chjj commented 11 years ago

This will either be solved with the fix referenced above, or from the addition of gfm line breaks.