Module: Syntropy::Markdown

Defined in:
lib/syntropy/markdown.rb

Overview

Markdown parsing.

Defined Under Namespace

Classes: Controller

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

.make_controller(env, atts, md) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/syntropy/markdown.rb', line 109

def make_controller(env, atts, md)
  Controller.new(env, atts, md).to_proc
  # layout = setup_layout_template(env, atts)
  
  # ->(req) {
  #   case req.method
  #   when 'head'
  #     req.respond_html(nil)
  #   when 'get'
  #     html = render_md(env, atts, md)
  #     req.respond_html(html)
  #   else
  #     req.respond(nil, ':status' => HTTP::METHOD_NOT_ALLOWED)
  #   end
  # }
end

.parse_file(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>



95
96
97
98
99
100
101
102
# File 'lib/syntropy/markdown.rb', line 95

def parse_file(path, env)
  md = IO.read(path) || ''
  atts = {}
  atts[:url] = path_to_url(path, env[:app_root]) if env[:app_root]
  parse_date(atts, path)

  parse_md(atts, md)
end

.parse_md(atts, md) ⇒ Object



104
105
106
107
# File 'lib/syntropy/markdown.rb', line 104

def parse_md(atts, md)
  html = parse_content(atts, md)
  [atts, html]
end