I am not able to get a line break <br>, even if there is a line with spaces and newline in the content. Is there any way this can enabled in redcarpet.
http://daringfireball.net/projects/markdown/syntax#p
"When you do want to insert a
break tag using Markdown, you end a line with two or more spaces, then type return."
Why is redcarpet not detecting the empty space line ?
Loading development environment (Rails 3.2.3)
irb(main):001:0> rendere = Redcarpet::Render::HTML.new(:hard_wrap => true)
=> #<Redcarpet::Render::HTML:0xa2cc414>
irb(main):002:0> markdown = Redcarpet::Markdown.new(rendere, :autolink => true, :space_after_headers => true)
=> #<Redcarpet::Markdown:0x98ab0c0>
irb(main):003:0> markdown.render("hi how are you doing\n \nFirst line in the next paragraph\n \nFirst line in the third paragraph\n")
=> "<p>hi how are you doing</p>\n\n<p>First line in the next paragraph</p>\n\n<p>First line in the third paragraph</p>\n"
irb(main):004:0> markdown.render("hi how are you doing\r\n \r\nFirst line in the next paragraph\r\n \r\nFirst line in the third paragraph\r\n")
=> "<p>hi how are you doing</p>\n\n<p>First line in the next paragraph</p>\n\n<p>First line in the third paragraph</p>\n"
irb(main):005:0>
The
<br>
elements are not added if the line is the last in a paragraph – only if there is something on the next line. For example this markdown (where all the lines have two trailing spaces):produces this HTML with Redcarpet:
Your example consists of three single line paragraphs, so each line is the last in the paragraph and doesn’t have the
<br>
added.This behaviour is the same as the original Markdown.pl (basically – the output isn’t identical but
<br>
s are added to the same lines).