Class: Troy::Markdown
- Inherits:
-
Object
- Object
- Troy::Markdown
- Defined in:
- lib/troy/markdown.rb
Defined Under Namespace
Modules: PrismJs, Rouge Classes: Renderer
Constant Summary collapse
- HEADING_ID =
Match the id portion of a header, as in ‘# Title #custom-id`.
/^(?<text>.*?)(?: {#(?<id>.*?)})?$/
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.
69 70 71 |
# File 'lib/troy/markdown.rb', line 69 def initialize(markup) @markup = markup end |
Instance Attribute Details
#markup ⇒ Object (readonly)
Set the Markdown markup that must be rendered.
67 68 69 |
# File 'lib/troy/markdown.rb', line 67 def markup @markup end |
Instance Method Details
#renderer ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/troy/markdown.rb', line 73 def renderer @renderer ||= Redcarpet::Markdown.new(Renderer, autolink: true, space_after_headers: true, fenced_code_blocks: true, footnotes: true, tables: true, underline: true, strikethrough: true, highlight: true) end |
#to_html ⇒ Object
85 86 87 |
# File 'lib/troy/markdown.rb', line 85 def to_html renderer.render(markup) end |