Can anyone explain me how does :hard_wrap work?

179 Views Asked by At

I don't undestand how to create a new line using Markdown Redcarpet. I type

Line 1
Line 2

But I see

Line 1 Line 2

In my helper I have markdown = Redcarpet::Markdown.new(MarkdownRenderer, hard_wrap: true, autolink: true, space_after_headers: true)

1

There are 1 best solutions below

1
On

According to the Redcarpet manual, the auto_wrap option goes into the Renderer initializer like this:

markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(hard_wrap: true), autolink: true, space_after_headers: true)

puts markdown.render("Line 1\n Line 2")

which gives me this output

<p>Line 1<br>
 Line 2</p>

https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch

Please note that I couldn't find a MarkdownRenderer class as Redcarpet comes only with a Redcarpet::Render::HTML and Redcarpet::Render::XHTML built in renderer.