Module: MarkdownHelper

Included in:
ActionView::Base
Defined in:
app/helpers/markdown_helper.rb

Instance Method Summary collapse

Instance Method Details

#markdown(text, options = nil) ⇒ Object

This method returns the given markdown code rendered as html. Have a look at these sources:

* http://railscasts.com/episodes/272-markdown-with-redcarpet
* https://github.com/vmg/redcarpet
* http://daringfireball.net/projects/markdown/syntax


8
9
10
11
12
# File 'app/helpers/markdown_helper.rb', line 8

def markdown(text, options = nil)
  markdown_options = options || {autolink: true, no_intraemphasis: true, fenced_code: true, gh_blockcode: true}
  renderer_options = options || {hard_wrap: true, filter_html: false}
  Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(renderer_options), markdown_options).render(text || "").html_safe
end