pmd/docs/_plugins/details_block.rb
Clément Fournier 79b2de8549 Put designer wiki doc on the website
Fix absolute links

Add css for details tag

Add installation doc
2019-07-31 19:01:11 +02:00

23 lines
739 B
Ruby

# Mimics an HTML <details> element
# Courtesy of https://github.com/towbi (https://gist.github.com/towbi/a67fda47e075d2b7fa4764bb42605063)
class DetailsTag < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@caption = markup
end
def render(context)
site = context.registers[:site]
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
# below Jekyll 3.x use this:
# converter = site.getConverterImpl(::Jekyll::Converters::Markdown)
caption = converter.convert(@caption).gsub(/<\/?p[^>]*>/, '').chomp
body = converter.convert(super(context))
"<details><summary>#{caption}</summary>#{body}</details>"
end
end
Liquid::Template.register_tag('details', DetailsTag)