aboutsummaryrefslogtreecommitdiff
path: root/docs/_plugins/callout.rb
blob: 29ecbc99d7791ce036e4262fc1284c5ed9ea0f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Source: http://stackoverflow.com/questions/19169849/how-to-get-markdown-processed-content-in-jekyll-tag-plugin

module Jekyll
  module Tags
    class CalloutTag < Liquid::Block

      def initialize(tag_name, type, tokens)
        super
        @type = type
        if type == "danger"
          @type = "danger"
        elsif type == "warning"
          @type = "warning"
        elsif type == "info"
          @type = "info"
        end
      end

      def render(context)
        site = context.registers[:site]
        converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
        output = converter.convert(super(context))
        "<div class=\"bd-callout bd-callout-#{@type}\">#{output}</div>"
      end
    end
  end
end

Liquid::Template.register_tag('callout', Jekyll::Tags::CalloutTag)