Class: Gollum::Filter::PandocBib

Inherits:
Gollum::Filter show all
Defined in:
lib/gollum-lib/filter/pandoc_bib.rb

Overview

When using pandoc, put relevant bibliography metadata extracted in the YAML filter back in the document so it gets passed on to pandoc.

Constant Summary collapse

BIB_PATH_KEYS =
['bibliography', 'csl']
BIB_KEYS =
['link-citations', 'nocite']
ALL_BIB_KEYS =
BIB_PATH_KEYS + BIB_KEYS

Constants inherited from Gollum::Filter

PLACEHOLDER_PATTERN

Instance Attribute Summary

Attributes inherited from Gollum::Filter

#close_pattern, #open_pattern

Instance Method Summary collapse

Methods inherited from Gollum::Filter

#initialize

Methods included from Helpers

#path_to_link_text, #trim_leading_slashes

Constructor Details

This class inherits a constructor from Gollum::Filter

Instance Method Details

#extract(data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gollum-lib/filter/pandoc_bib.rb', line 15

def extract(data)
  return data unless supported_format? && 
   = {}
  .merge!(@markup..select {|key, _value| BIB_KEYS.include?(key)})

  BIB_PATH_KEYS.each do |bibliography_key|
    if path = @markup.[bibliography_key]
      next unless file = @markup.wiki.file(path)
      [bibliography_key] = path_for_bibfile(file)
    end
  end
  .empty? ? data : "#{.to_yaml}---\n#{data}"
end

#process(data) ⇒ Object



11
12
13
# File 'lib/gollum-lib/filter/pandoc_bib.rb', line 11

def process(data)
  data
end