RailsCasts Pro episodes are now free!

Learn more or hide this

Braulio Carreno's Profile

GitHub User: bcarreno

Site: http://www.carreno.me/

Comments by Braulio Carreno

Avatar

Albino has been deprecated in favor of pygments.rb. This code combines both redcarpet 2.1 and pygments.rb

ruby
module ApplicationHelper
  class HTMLwithPygments < Redcarpet::Render::HTML
    def block_code(code, language)
      Pygments.highlight(code, :lexer => language)
    end
  end

  def markdown(text)
    renderer = HTMLwithPygments.new(:hard_wrap => true)
    options = {
      :fenced_code_blocks => true,
      :no_intra_emphasis => true,
      :autolink => true,
      :strikethrough => true,
      :lax_html_blocks => true,
      :superscript => true
    }
    Redcarpet::Markdown.new(renderer, options).render(text)
  end
end