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
citations_search(search_key, author = nil)
click to toggle source
# File lib/middleman-citation.rb, line 38 def citations_search(search_key, author = nil) entries_matching_key = config.bibtex.query(search_key) entries = if author then search_by_author(entries_matching_key, author) else entries_matching_key end entries.sort { |x, y| y.year.to_i <=> x.year.to_i }.map(&:key) end
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