2012-07-25 21:01:01 +00:00
|
|
|
MKD_SAFE_RENDERER = Redcarpet::Markdown.new(
|
2017-05-02 13:58:18 +00:00
|
|
|
Redcarpet::Render::HTML.new(:filter_html => true, :hard_wrap => true, :with_toc_data => true),
|
2012-04-06 21:46:44 +00:00
|
|
|
:no_intra_emphasis => true,
|
|
|
|
:autolink => true
|
|
|
|
)
|
2012-07-25 21:01:01 +00:00
|
|
|
|
|
|
|
MKD_RENDERER = Redcarpet::Markdown.new(
|
2017-05-02 13:58:18 +00:00
|
|
|
Redcarpet::Render::HTML.new(:with_toc_data => true),
|
2012-07-25 21:01:01 +00:00
|
|
|
:no_intra_emphasis => true,
|
|
|
|
:autolink => true
|
|
|
|
)
|
2015-03-31 11:07:22 +00:00
|
|
|
|
|
|
|
module MarkdownHandler
|
|
|
|
def self.erb
|
|
|
|
@erb ||= ActionView::Template.registered_template_handler(:erb)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.call(template)
|
|
|
|
compiled_source = erb.call(template)
|
2015-06-24 17:35:42 +00:00
|
|
|
"MKD_RENDERER.render(begin;#{compiled_source};end).html_safe"
|
2015-03-31 11:07:22 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ActionView::Template.register_template_handler :md, MarkdownHandler
|