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.



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

def initialize(markup)
  @markup = markup
end

Instance Attribute Details

#markupObject (readonly)

Set the Markdown markup that must be rendered.



27
28
29
# File 'lib/troy/markdown.rb', line 27

def markup
  @markup
end

Instance Method Details

#rendererObject



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

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

#to_htmlObject



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

def to_html
  renderer.render(markup)
end