class Gollum::Filter::Frontmatter

Public Instance Methods

extract(data) click to toggle source

replaces the library’s weird syntax with traditional YAML frontmatter

# File lib/frontmatter.rb, line 4
def extract(data)

  data.gsub(/\A---\s*$(.*)^---\s*$\n?/m) do
    yaml = $1
    hash = YAML.load(yaml)
    @markup.metadata ||= {}
    if Hash === hash
      @markup.metadata.update(hash)
    end

    '' #replace with nothing
  end
end
process(data) click to toggle source

passthrough

# File lib/frontmatter.rb, line 19
def process(data)
  data
end