Last Updated: February 25, 2016
·
862
· rebyn

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.

2 Responses
Add your response

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 ·

Hmm, how did you compare both gems' performance?

over 1 year ago ·