Class: Mdify::Renderer
- Inherits:
-
Object
- Object
- Mdify::Renderer
- Defined in:
- lib/mdify/renderer.rb
Constant Summary collapse
- MARKDOWN_OPTIONS =
{ autolink: true, fenced_code_blocks: true, tables: true, strikethrough: true, superscript: true, no_intra_emphasis: true, space_after_headers: true }.freeze
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(filename) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(filename) ⇒ Renderer
Returns a new instance of Renderer.
17 18 19 20 |
# File 'lib/mdify/renderer.rb', line 17 def initialize(filename) @title = File.basename(filename) @content = File.read(filename) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
15 16 17 |
# File 'lib/mdify/renderer.rb', line 15 def content @content end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
15 16 17 |
# File 'lib/mdify/renderer.rb', line 15 def title @title end |
Instance Method Details
#render ⇒ Object
22 23 24 25 26 27 |
# File 'lib/mdify/renderer.rb', line 22 def render markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, MARKDOWN_OPTIONS) html = markdown.render(@content) document = render_html(@title, html) open_in_browser(write_html(document)) end |