Class: Troy::Markdown
- Inherits:
-
Object
- Object
- Troy::Markdown
- Defined in:
- lib/troy/markdown.rb
Defined Under Namespace
Modules: PrismJs, Rouge Classes: Renderer
Instance Attribute Summary collapse
-
#markup ⇒ Object
readonly
Set the Markdown markup that must be rendered.
Instance Method Summary collapse
-
#initialize(markup) ⇒ Markdown
constructor
A new instance of Markdown.
- #renderer ⇒ Object
- #to_html ⇒ Object
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
#markup ⇒ Object (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
#renderer ⇒ Object
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_html ⇒ Object
42 43 44 |
# File 'lib/troy/markdown.rb', line 42 def to_html renderer.render(markup) end |