Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lawitschka
Created September 23, 2013 07:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawitschka/6667570 to your computer and use it in GitHub Desktop.
Save lawitschka/6667570 to your computer and use it in GitHub Desktop.
Rendering sections of ERb templates in Markdown with Rails
<%= markdown do %>
# About
a paragraph....
* one
* two
<% end %>
module MarkdownHelper
class Markdown
class << self
def renderer
@@renderer ||= Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
:autolink => true,
:no_intra_emphasis => true,
:tables => true,
:fenced_code_blocks => true,
:disable_indented_code_blocks => true,
:filter_html => false,
:with_toc_data => true
)
end
end
end
def markdown(&block)
content = capture(&block)
Markdown.renderer.render(content).html_safe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment