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.



12
13
14
15
# File 'lib/madness/markdown_document.rb', line 12

def initialize(markdown, title: nil)
  @markdown = markdown
  @title = title || ''
end

Instance Attribute Details

#markdownObject (readonly)

Returns the value of attribute markdown.



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

def markdown
  @markdown
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#textObject



17
18
19
20
21
22
23
24
25
# File 'lib/madness/markdown_document.rb', line 17

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



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

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