mdiep / MMMarkdown

An Objective-C framework for converting Markdown to HTML.
MIT License
1.25k stars 168 forks source link

Line breaks weird behavior. #65

Closed njuri closed 9 years ago

njuri commented 9 years ago

Input: Lorem ipsum.\n \n Lorem ipsum. Output: <"p>Lorem ipsum.<"/p> <"p>Lorem ipsum.<"/p>

Input: Lorem ipsum.\n \n \n Lorem ipsum. Output: <"p>Lorem ipsum.<"/p> <"p>Lorem ipsum.<"/p>

So regardless of how much line breaks are entered, output is markdown without empty line.

P.S There're no quotes inside paragraph tags in output, I've put them there to prevent github markdown parsing.

mdiep commented 9 years ago

So your input looks like this? (You can use Markdown to tell GitHub that the input is code to render it as-is.)

Lorem ipsum.

Lorem ipsum.

And your output is like this?

<p>Lorem ipsum.</p>
<p>Lorem ipsum.</p>

If so, that looks correct to me. If you want an empty line between the paragraphs, you probably need to use CSS or something to adjust the spacing. How are you displaying the output?

njuri commented 9 years ago

Thanks for answering, but in GitHub (e.g writing readme) you can put two line breaks (as in my input, you understood it correctly) and get empty line between two paragraphs.

mdiep commented 9 years ago

The empty line you get on GitHub is the result of the to <p> tags in the above output. You can change how those are rendered to display or not display an empty line between the paragraphs.

njuri commented 9 years ago

So I tried to use an MMMarkdownExtensionsGitHubFlavored extension, but it still creates just two paragraphs next to each other without empty line between.

mdiep commented 9 years ago

You don't need to use MMMarkdownExtensionsGitHubFlavored.

This:

<p>Lorem ipsum.</p>
<p>Lorem ipsum.</p>

should render with a blank line between the paragraphs. It is the correct output. If there's not a blank line, then you need to change how the output is displayed.

njuri commented 9 years ago

Instead of just passing this to

HTMLStringWithMarkdown(textView.text)

I did

HTMLStringWithMarkdown(textView.text.stringByReplacingOccurrencesOfString("\n", withString:" </br>"))

And this did exactly what I wanted, so since it wasn't library problem, I think this issue could be closed.