quote.rb 676 Bytes
Newer Older
Sylvester Keil's avatar
Sylvester Keil committed
1 2 3 4 5
module Jekyll
  class Scholar

    class QuoteTag < Liquid::Block
      include Scholar::Utilities
6

7
      attr_reader :pages
8

Sylvester Keil's avatar
Sylvester Keil committed
9 10
      def initialize(tag_name, arguments, tokens)
        super
11

Sylvester Keil's avatar
Sylvester Keil committed
12
        @config = Scholar.defaults.dup
13
        @keys, arguments = split_arguments arguments
Sylvester Keil's avatar
Sylvester Keil committed
14 15 16 17
      end

      def render(context)
        set_context_to context
18

Sylvester Keil's avatar
Sylvester Keil committed
19 20
        quote = super.strip.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')
        quote = content_tag :p, quote
21 22 23

        citation = cite keys

Sylvester Keil's avatar
Sylvester Keil committed
24
        quote << content_tag(:cite, citation)
25

Sylvester Keil's avatar
Sylvester Keil committed
26 27
        content_tag :blockquote, quote
      end
28

Sylvester Keil's avatar
Sylvester Keil committed
29
    end
30

Sylvester Keil's avatar
Sylvester Keil committed
31 32 33
  end
end

34
Liquid::Template.register_tag('quote', Jekyll::Scholar::QuoteTag)