Module: Syntropy::Markdown

Defined in:
lib/syntropy/markdown.rb

Overview

Markdown parsing.

Constant Summary collapse

FRONT_MATTER_REGEXP =
/\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
YAML_OPTS =
{
  permitted_classes: [Date],
  symbolize_names: true
}.freeze

Class Method Summary collapse

Class Method Details

.parse(path, env) ⇒ Array

Parses the markdown file at the given path.

Parameters:

  • path (String)

    file path

Returns:

  • (Array)

    an tuple containing properties<Hash>, contents<String>



19
20
21
22
23
24
25
26
27
28
# File 'lib/syntropy/markdown.rb', line 19

def parse(path, env)
  content = IO.read(path) || ''
  atts = {}

  parse_date(path, atts)
  content = parse_content(content, atts)
  atts[:url] = path_to_url(path, env[:app_root]) if env[:app_root]

  [atts, content]
end