Class: Madness::MarkdownDocument

Inherits:
Object
  • Object
show all
Includes:
ServerHelper
Defined in:
lib/madness/markdown_document.rb

Overview

Handle a pure markdown document.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#markdownObject (readonly)

Returns the value of attribute markdown.



9
10
11
# File 'lib/madness/markdown_document.rb', line 9

def markdown
  @markdown
end

#titleObject (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

#textObject



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_htmlObject



26
27
28
# File 'lib/madness/markdown_document.rb', line 26

def to_html
  @to_html ||= renderer.render text
end