From b06bc1bd1e5833fe2ff9aa3f92b86e2b845ce32b Mon Sep 17 00:00:00 2001 From: Rachel Lambda Samuelsson Date: Sun, 24 Dec 2023 22:44:22 +0100 Subject: [PATCH] add details plugin --- _plugins/cd.rb | 2 +- _plugins/details_tag.rb | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 _plugins/details_tag.rb diff --git a/_plugins/cd.rb b/_plugins/cd.rb index 149f9e2..c1eba0f 100644 --- a/_plugins/cd.rb +++ b/_plugins/cd.rb @@ -42,7 +42,7 @@ EOF svg = File.read("#{dir}/optimized_cd.svg") return < - A commutative diagram + A commutative diagram
#{@caption}
EOF diff --git a/_plugins/details_tag.rb b/_plugins/details_tag.rb new file mode 100644 index 0000000..0bf0594 --- /dev/null +++ b/_plugins/details_tag.rb @@ -0,0 +1,23 @@ +# from http://movb.de/jekyll-details-support.html +module Jekyll + module Tags + 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) + caption = converter.convert(@caption).gsub(/<\/?p[^>]*>/, '').chomp + body = converter.convert(super(context)) + "
#{caption}#{body}
" + end + + end + end +end + +Liquid::Template.register_tag('details', Jekyll::Tags::DetailsTag)