Skip to content

Instantly share code, notes, and snippets.

@bigsweater
Created September 21, 2013 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigsweater/6647871 to your computer and use it in GitHub Desktop.
Save bigsweater/6647871 to your computer and use it in GitHub Desktop.
A Middleman helper that creates a `<% markdown do %>` method to parse markdown text inside ERb templates, so you can use markdown for content and ERb for layout in the same file. (Similar to the :markdown HAML method.)
module MD
def renderer
Redcarpet::Render::HTML.new(
:no_intra_emphasis => true,
:tables => true,
:fenced_code_blocks => true,
:disable_indented_code_blocks => true,
:autolink => true,
:filter_html => false,
:with_toc_data => true
)
end
def markdown
Redcarpet::Markdown.new(renderer)
end
def md
markdown.render(yield)
end
end
helpers MD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment