class Middleman::CitationExtension

Public Class Methods

new(app, options_hash={}, &block) click to toggle source
Calls superclass method
# File lib/middleman-citation.rb, line 14
def initialize(app, options_hash={}, &block)
  super
  app.config[:bibtex] = BibTeX.open(options.bibtex, :filter => 'latex')
  app.config[:cite_style] = options.style
  app.config[:cite_format] = options.format
end

Public Instance Methods

cite_full(key) click to toggle source

Given a BibTeX citation return a formatted string according to how the setting of the style option Params:

key

bibtex key located in the BibTeX file defined in the config

# File lib/middleman-citation.rb, line 26
def cite_full(key)
  Citations::cite_full(key, config.bibtex, config.cite_style, config.cite_format)
end
cite_inline(key) click to toggle source

Given a BibTeX citation return a block containing the citation that we can embed in a webpage inline Params:

key

bibtex key located in the BibTeX file defined in the config

# File lib/middleman-citation.rb, line 34
def cite_inline(key)
  Citations::cite_inline(key, config.bibtex, config.cite_style)
end
search_by_author(entries, author) click to toggle source
# File lib/middleman-citation.rb, line 51
def search_by_author(entries, author)
  bib_author = BibTeX::Name.parse(author)
  entries.select do |e|
    e.respond_to?(:author) && 
      e.author && 
      e.author.include?(bib_author)
  end
end