Class: Troy::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/troy/markdown.rb

Defined Under Namespace

Modules: PrismJs, Rouge Classes: Renderer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(markup) ⇒ Markdown

Returns a new instance of Markdown.



31
32
33
# File 'lib/troy/markdown.rb', line 31

def initialize(markup)
  @markup = markup
end

Instance Attribute Details

#markupObject (readonly)

Set the Markdown markup that must be rendered.



29
30
31
# File 'lib/troy/markdown.rb', line 29

def markup
  @markup
end

Instance Method Details

#rendererObject



35
36
37
38
39
40
41
# File 'lib/troy/markdown.rb', line 35

def renderer
  @renderer ||= Redcarpet::Markdown.new(Renderer,
                                        autolink: true,
                                        space_after_headers: true,
                                        fenced_code_blocks: true,
                                        footnotes: true)
end

#to_htmlObject



43
44
45
# File 'lib/troy/markdown.rb', line 43

def to_html
  renderer.render(markup)
end