Skip to content

Instantly share code, notes, and snippets.

@nacengineer
Created April 29, 2012 20:53
Show Gist options
  • Save nacengineer/2553194 to your computer and use it in GitHub Desktop.
Save nacengineer/2553194 to your computer and use it in GitHub Desktop.
Railscast #272 with Pygments.rb and Redcloth 2
# Authored by Braulio Carreno on railscasts site. Put here mostly as a reference for me.
# also remember to replace albino gem with pygments.rb gem
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment