Class: Madness::MarkdownDocument
- Inherits:
-
Object
- Object
- Madness::MarkdownDocument
- Includes:
- ServerHelper
- Defined in:
- lib/madness/markdown_document.rb
Overview
Handle a pure markdown document.
Instance Attribute Summary collapse
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(markdown, title: nil) ⇒ MarkdownDocument
constructor
A new instance of MarkdownDocument.
- #text ⇒ Object
- #to_html ⇒ Object
Methods included from ServerHelper
#config, #disallowed_static?, #docroot, #find_static_file, #log, #theme
Constructor Details
#initialize(markdown, title: nil) ⇒ MarkdownDocument
Returns a new instance of MarkdownDocument.
11 12 13 14 |
# File 'lib/madness/markdown_document.rb', line 11 def initialize(markdown, title: nil) @markdown = markdown @title = title || '' end |
Instance Attribute Details
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
9 10 11 |
# File 'lib/madness/markdown_document.rb', line 9 def markdown @markdown end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/madness/markdown_document.rb', line 9 def title @title end |
Instance Method Details
#text ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/madness/markdown_document.rb', line 16 def text @text ||= begin result = markdown result = parse_toc(result) if config.auto_toc result = parse_shortlinks(result) if config.shortlinks result = prepend_h1(result) if config.auto_h1 result end end |
#to_html ⇒ Object
26 27 28 |
# File 'lib/madness/markdown_document.rb', line 26 def to_html @to_html ||= renderer.render text end |