Created
September 21, 2013 06:41
-
-
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.)
This file contains 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
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