Skip to content

Instantly share code, notes, and snippets.

@clooth
Created December 13, 2011 13:01
Show Gist options
  • Save clooth/1472055 to your computer and use it in GitHub Desktop.
Save clooth/1472055 to your computer and use it in GitHub Desktop.
how about this
module ApplicationHelper
def markdown(text, *renderer)
case renderer[0]
props = {
hard_wrap: true,
gh_blockcode: true,
safe_links_only: true,
filter_html: true
}
when :authored
props[:filter_html] = false
else
props[:no_images] = true; props[:no_styles] = true
end
redcarpet = Redcarpet::Markdown.new(HTMLwithAlbino.new(props),
space_after_headers: true, fenced_code_blocks: true,
autolink: true, no_intra_emphasis: true,
strikethrough: true, superscripts: true
)
redcarpet.render(text).html_safe
end
end
# create a custom renderer that allows highlighting of code blocks
class HTMLwithAlbino < Redcarpet::Render::HTML
def block_code(code, language)
Albino.colorize(code, language)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment