class Marsdawn::Source::Document
Attributes
front_matter[RW]
Public Class Methods
new(text, options={})
click to toggle source
Calls superclass method
# File lib/marsdawn/source/document.rb, line 22 def initialize text, options={} doc = FrontMatter.new(text) @front_matter = {} options[:input] = 'Marsdawn' super doc.content, options @front_matter.merge! Kramdown::Parser::Marsdawn.front_matter @front_matter.merge! doc.attr end
read(path, title=nil, options={})
click to toggle source
# File lib/marsdawn/source/document.rb, line 12 def self.read path, title=nil, options={} text = open(path).read new(text, options).tap do |doc| title = File.basename(path, '.*') if title.nil? title = title.gsub(/^\d+_/, '').gsub(/_|-/, ' ').capitalize doc.front_matter[:title] ||= title doc.front_matter[:link_key] ||= title end end