Class: Jekyll::Scholar::ReferenceTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
Utilities
Defined in:
lib/jekyll/scholar/tags/reference.rb

Instance Attribute Summary collapse

Attributes included from Utilities

#bibtex_file, #config, #context, #query, #site

Instance Method Summary collapse

Methods included from Utilities

#base_url, #bibliography, #bibtex_options, #bibtex_path, #cite, #cite_details, #cited_references, #content_tag, #details_file_for, #details_link_for, #details_path, #entries, #extend_path, #generate_details?, #link_to, #set_context_to

Constructor Details

#initialize(tag_name, arguments, tokens) ⇒ ReferenceTag

Returns a new instance of ReferenceTag.



9
10
11
12
13
14
# File 'lib/jekyll/scholar/tags/reference.rb', line 9

def initialize(tag_name, arguments, tokens)
  super

  @config = Scholar.defaults.dup
  @key, @file = arguments.strip.split(/\s*,\s*/, 2)
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/jekyll/scholar/tags/reference.rb', line 7

def file
  @file
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/jekyll/scholar/tags/reference.rb', line 7

def key
  @key
end

Instance Method Details

#render(context) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jekyll/scholar/tags/reference.rb', line 16

def render(context)
  set_context_to context
  bib = unless file.nil?
          BibTeX.open(file, { :filter => :latex })
        else
          set_context_to context
          bibliography
        end

  entry = bib[key]

  if bib.key?(key)
    CiteProc.process entry.to_citeproc,
                     :style => config['style'],
                     :locale => config['locale'],
                     :format => 'html'
  else
    "(missing reference)"
  end
rescue
  "(#{key})"
end