bibliography.rb 999 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
12

        optparse(arguments)
13
14
15
      end

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

18
19
        references = entries

Sylvester Keil's avatar
Sylvester Keil committed
20
21
22
        references.select! do |e|
          cited_references.include? e.key
        end if cited_only?
23

Sylvester Keil's avatar
Sylvester Keil committed
24
        bibliography = references.each_with_index.map { |entry, index|
25
          reference = bibliography_tag(entry, index + 1)
26

27
          if generate_details?
28
29
            reference << link_to(details_link_for(entry),
              config['details_link'], :class => config['details_link_class'])
Sylvester Keil's avatar
Sylvester Keil committed
30
          end
31

Sylvester Keil's avatar
Sylvester Keil committed
32
          content_tag :li, reference
33
        }.join("\n")
Sylvester Keil's avatar
Sylvester Keil committed
34

35
        content_tag :ol, bibliography, :class => config['bibliography_class']
36
      end
37
    end
38

39
40
41
  end
end

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