Rendering Markdown with RedCarpet in Rails 15 november 2021

Go to app/Gemfile and add

gem 'redcarpet'

now in rails root directory

bundle install

Open app/helpers/application_helper.rb and add the following function:

def markdown(text)
    options = [:hard_wrap, :autolink, :no_intra_emphasis, :fenced_code_blocks]
    Markdown.new(text, *options).to_html.html_safe
end

Edit your view to include

markdown(@changelogs)

And done!

Vincent Bakker