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.
Written by Tu Hoang
Related protips
2 Responses
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#