vb4wbq
Last Updated: February 25, 2016
·
548
· rebyn
3

Markdown with RDiscount

Use RDiscount to mark up your content in Rails.

Put this in your Gemfile:

gem 'rdiscount'

Then run bundle install</code>. Wait till everything finishes, restart your server.

Important:

You have to restart your server in order for the gem to work.

Add this to your app/helpers/application_helpers.rb</code>

module ApplicationHelper
  def markdown(text)
    RDiscount.new(text).to_html.html_safe
  end
end

Wrap the Markdown-formatted content with this:

<%= raw markdown(@blog.article) %>
  • Tu.
Say Thanks
Respond

2 Responses
Add your response

1531
Me

I prefer Redcarpet gem that use Sunshine native library. It's faster and has a little bit better support (at least GitHub is not small company).

over 1 year ago ·
1532
3

Hmm, how did you compare both gems' performance?

over 1 year ago ·