Class: MarkdownToWord::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_to_word/document.rb

Constant Summary collapse

YAML_FRONT_MATTER_REGEXP =
/\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(markdown = "") ⇒ Document



9
10
11
# File 'lib/markdown_to_word/document.rb', line 9

def initialize(markdown="")
  @raw_markdown = markdown
end

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



4
5
6
# File 'lib/markdown_to_word/document.rb', line 4

def html
  @html
end

#templateObject

Returns the value of attribute template.



4
5
6
# File 'lib/markdown_to_word/document.rb', line 4

def template
  @template
end

Instance Method Details

#contentsObject



25
26
27
# File 'lib/markdown_to_word/document.rb', line 25

def contents
  @contents ||= Htmltoword::Document.create(html, template, true)
end

#hashObject



21
22
23
# File 'lib/markdown_to_word/document.rb', line 21

def hash
  @hash ||= Digest::MD5.hexdigest(html)
end

#markdownObject



13
14
15
# File 'lib/markdown_to_word/document.rb', line 13

def markdown
  @raw_markdown.split(YAML_FRONT_MATTER_REGEXP).last
end