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.
102 103 104 |
# File 'lib/troy/markdown.rb', line 102 def initialize(markup) @markup = markup end |
Instance Attribute Details
#markup ⇒ Object (readonly)
Set the Markdown markup that must be rendered.
100 101 102 |
# File 'lib/troy/markdown.rb', line 100 def markup @markup end |
Instance Method Details
#renderer ⇒ Object
[View source]
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/troy/markdown.rb', line 106 def renderer @renderer ||= Redcarpet::Markdown.new(Renderer, autolink: true, space_after_headers: true, fenced_code_blocks: true, footnotes: true, tables: true, strikethrough: true, highlight: true) end |
#to_html ⇒ Object
[View source]
117 118 119 |
# File 'lib/troy/markdown.rb', line 117 def to_html renderer.render(markup) end |