Created
April 29, 2012 20:53
-
-
Save nacengineer/2553194 to your computer and use it in GitHub Desktop.
Railscast #272 with Pygments.rb and Redcloth 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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