Commit a682fca6 authored by Georgios Gousios's avatar Georgios Gousios

Tag to print a formatted citation

parent 49c165c1
......@@ -13,4 +13,5 @@ require 'jekyll/scholar/tags/bibliography'
require 'jekyll/scholar/tags/cite'
require 'jekyll/scholar/tags/cite_details'
require 'jekyll/scholar/tags/quote'
require 'jekyll/scholar/tags/print_cite'
require 'jekyll/scholar/generators/details'
module Jekyll
class Scholar
class PrintCiteTag < Liquid::Tag
include Scholar::Utilities
attr_reader :key, :file
def initialize(tag_name, arguments, tokens)
super
@config = Scholar.defaults.dup
@key, @file = arguments.strip.split(/\s*,\s*/, 2)
end
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
end
end
end
Liquid::Template.register_tag('print_cite', Jekyll::Scholar::PrintCiteTag)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment