bibliography.rb 923 Bytes
Newer Older
1
2
3
4
module Jekyll
  class Scholar

    class BibliographyTag < Liquid::Tag
5
      include Scholar::Utilities
6
7
8
  
      def initialize(tag_name, arguments, tokens)
        super
Sylvester Keil's avatar
Sylvester Keil committed
9

10
        @config = Scholar.defaults.dup
11
        @bibtex_file = arguments.strip
12
13
14
      end

      def render(context)
Sylvester Keil's avatar
Sylvester Keil committed
15
        set_context_to context
16

Sylvester Keil's avatar
Sylvester Keil committed
17
18
        references = entries.map do |entry|
          reference = CiteProc.process entry.to_citeproc, :style => config['style'],
19
            :locale => config['locale'], :format => 'html'
Sylvester Keil's avatar
Sylvester Keil committed
20
21
22

          reference = content_tag :span, reference, :id => entry.key

23
          if generate_details?
Sylvester Keil's avatar
Sylvester Keil committed
24
            reference << link_to(details_link_for(entry), config['details_link'])
Sylvester Keil's avatar
Sylvester Keil committed
25
          end
Sylvester Keil's avatar
Sylvester Keil committed
26
27

          content_tag :li, reference
Sylvester Keil's avatar
Sylvester Keil committed
28
        end
Sylvester Keil's avatar
Sylvester Keil committed
29

Sylvester Keil's avatar
Sylvester Keil committed
30
        content_tag :ol, references.join("\n")
31
32
33
34
35
36
37
38
      end
      
    end
    
  end
end

Liquid::Template.register_tag('bibliography', Jekyll::Scholar::BibliographyTag)