Class: Slimdown::PageParser

Inherits:
Object
  • Object
show all
Defined in:
lib/slimdown/page_parser.rb

Overview

Internal class to manage parsing the markdown document.

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PageParser

Returns a new instance of PageParser.

Parameters:

  • path (String)

    The absolute path to the markdown document.



8
9
10
11
12
# File 'lib/slimdown/page_parser.rb', line 8

def initialize(path)
  @path = path

  parse_file
end

Instance Method Details

#bodyKramdown::Document

The parsed markdown document body.

Returns:

  • (Kramdown::Document)

    a markdown document object.



33
34
35
# File 'lib/slimdown/page_parser.rb', line 33

def body
  Kramdown::Document.new(@body_text)
end

#headersHash

A hash of the headers in the document

Example:

{
  "title" => "Test title",
  "template" => "test_template",
}

Returns:

  • (Hash)

    document headers



23
24
25
26
27
28
# File 'lib/slimdown/page_parser.rb', line 23

def headers
  head = {}
  head = YAML.load @header_text unless @header_text == ''

  head
end