Module: MarkdownHelper

Defined in:
app/helpers/markdown_helper.rb

Instance Method Summary collapse

Instance Method Details

#markdown(text) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/markdown_helper.rb', line 2

def markdown(text)
  return "" if text.blank?

  renderer = Redcarpet::Render::HTML.new(
    hard_wrap: true,
    link_attributes: { target: "_blank", rel: "noopener" }
  )

  markdown = Redcarpet::Markdown.new(renderer,
    autolink: true,
    tables: true,
    fenced_code_blocks: true,
    strikethrough: true,
    superscript: true,
    no_intra_emphasis: true
  )

  markdown.render(text).html_safe
end