Redcarpet 2.0.1
Asked Answered
P

1

6

I'm following this tutorial but it keeps failing saying "undefined method `new' for Redcarpet:Module". I have gem "redcarpet" in my Gemfile. The piece of code that is failing:

Redcarpet.new(@post.content).to_html
Peng answered 27/12, 2011 at 17:24 Comment(1)
Just a quick sanity check... you ran 'bundle install' after changing your gemfile, right?Oca
P
14

Okay, it looks like Redcarpet 2 has completely changed the API. The following works:

markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
    :autolink => true, :space_after_headers => true)
raw markdown.render(@post_content.content)
Peng answered 27/12, 2011 at 20:26 Comment(1)
+1 I prefer to use markdown.render(@post_content.content).html_safe which also works. Not a fan of using raw anymore.Eiser

© 2022 - 2024 — McMap. All rights reserved.