aboutsummaryrefslogtreecommitdiff
path: root/_plugins/callout.rb
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2017-05-30 08:46:33 -0700
committerMark Otto <[email protected]>2017-05-30 08:46:33 -0700
commitd4eb0d4e739477fc51421eed29906addfd998a04 (patch)
tree5ffe09c63ac4e522890fc7b2b87c0a47b0f1a971 /_plugins/callout.rb
parent0c12ccbeb6fdf0dd3818f97260aa43c79108d377 (diff)
parentf95cbc5950bf31995f33023014c47a61665ffacc (diff)
downloadbootstrap-d4eb0d4e739477fc51421eed29906addfd998a04.tar.xz
bootstrap-d4eb0d4e739477fc51421eed29906addfd998a04.zip
Merge branch 'v4-docs-streamlined' of https://github.com/twbs/bootstrap into v4-docs-streamlined
Diffstat (limited to '_plugins/callout.rb')
-rw-r--r--_plugins/callout.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/_plugins/callout.rb b/_plugins/callout.rb
new file mode 100644
index 000000000..58453ecb4
--- /dev/null
+++ b/_plugins/callout.rb
@@ -0,0 +1,28 @@
+# 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.find_converter_instance(::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)