3294e2c9fa702dc5af8a1dd95655a2018904e766.svn-base 819 B

12345678910111213141516171819202122232425262728
  1. # Source: http://stackoverflow.com/questions/19169849/how-to-get-markdown-processed-content-in-jekyll-tag-plugin
  2. module Jekyll
  3. module Tags
  4. class CalloutTag < Liquid::Block
  5. def initialize(tag_name, type, tokens)
  6. super
  7. type.strip!
  8. if %w(info danger warning).include?(type)
  9. @type = type
  10. else
  11. puts "#{type} callout not supported. Defaulting to info"
  12. @type = "info"
  13. end
  14. end
  15. def render(context)
  16. site = context.registers[:site]
  17. converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
  18. output = converter.convert(super(context))
  19. "<div class=\"bd-callout bd-callout-#{@type}\">#{output}</div>"
  20. end
  21. end
  22. end
  23. end
  24. Liquid::Template.register_tag('callout', Jekyll::Tags::CalloutTag)