1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00
twbs--bootstrap/docs/_plugins/callout.rb
XhmikosR 8328344212 Use https when possible.
[ci skip]
2015-08-29 18:50:20 +03:00

28 lines
820 B
Ruby

# Source: https://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.strip!
if %w(info danger warning).include?(type)
@type = type
else
puts "#{type} callout not supported. Defaulting to 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)