0

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)

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
J.Luca
  • 208
  • 1
  • 10

1 Answers1

0

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.

  • it's strange. Because adding a commet with "Line 1\n Line 2" it doesn't work. It shows exactly "Line 1\n Line 2" – J.Luca Jul 26 '20 at 07:43