Class: Gollum::Filter::Frontmatter

Inherits:
Gollum::Filter
  • Object
show all
Defined in:
lib/frontmatter.rb

Instance Method Summary collapse

Instance Method Details

#extract(data) ⇒ Object

replaces the library’s weird syntax with traditional YAML frontmatter



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/frontmatter.rb', line 4

def extract(data)

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

    '' #replace with nothing
  end
end

#process(data) ⇒ Object

passthrough



19
20
21
# File 'lib/frontmatter.rb', line 19

def process(data)
  data
end