indragiek / CocoaMarkdown

Markdown parsing and rendering for iOS and OS X
MIT License
1.2k stars 158 forks source link

Support two empty spaces at the end of line to trigger line return #38

Closed iby closed 4 years ago

iby commented 8 years ago

If I understand correctly cmark does support this, like normal markdown syntax, but attributed string sees this break as a new paragraph. For example, the following markdown:

foo
bar

baz  
qux

Should render like this:

But attributed string renders like this:

Have a feeling I'm not the first one wondering about this. Anyone knows anything about this / can comment? If PR is needed, where should I start looking at?

johngibb commented 7 years ago

This is easy! The parser is already doing the right thing, but the renderer in this project needs to be modified.

You just need to modify parserFoundLineBreak in CMAttributedStringRenderer (https://github.com/indragiek/CocoaMarkdown/blob/master/CocoaMarkdown/CMAttributedStringRenderer.m#L217) to use a unicode line separator rather than a "\n":

[self appendString:@"\u2028"];

Feel free to make this change and submit a PR. I'm in the middle of a project, but will try and submit a PR for this at some point in the future if you don't.

indragiek commented 4 years ago

This was fixed in #35