Class: TechRadar::Rendering::Markdown

Inherits:
Object
  • Object
show all
Defined in:
app/models/tech_radar/rendering/markdown.rb

Instance Method Summary collapse

Constructor Details

#initializeMarkdown

Returns a new instance of Markdown.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/tech_radar/rendering/markdown.rb', line 4

def initialize
  require 'redcarpet'
  renderer = Redcarpet::Render::HTML.new(
        filter_html: true,
          no_styles: true,
    safe_links_only: true
  )
  @markdown = Redcarpet::Markdown.new(renderer,
                                      no_intra_emphasis: true,
                                                 tables: true,
                                     fenced_code_blocks: true,
                                               autolink: true,
                           disable_indented_code_blocks: true,
                                          strikethrough: true,
                                            superscript: true)
rescue LoadError => ex
  raise "Since you speecified markdown rendering, you must include the redcarpet gem in your app: #{ex.message}"
end

Instance Method Details

#render_text(text) ⇒ Object



23
24
25
# File 'app/models/tech_radar/rendering/markdown.rb', line 23

def render_text(text)
  @markdown.render(text).html_safe
end