add details plugin
This commit is contained in:
parent
ab3784c531
commit
b06bc1bd1e
|
@ -42,7 +42,7 @@ EOF
|
||||||
svg = File.read("#{dir}/optimized_cd.svg")
|
svg = File.read("#{dir}/optimized_cd.svg")
|
||||||
return <<EOF
|
return <<EOF
|
||||||
<figure class="cdfig">
|
<figure class="cdfig">
|
||||||
<img class="cd" style="width: #{@scale}%;" src="data:image/svg+xml;base64#{Base64.encode64(svg)}" alt="A commutative diagram"/>
|
<img class="cd" style="width: #{@scale}%;" src="data:image/svg+xml;base64,#{Base64.encode64(svg)}" alt="A commutative diagram"/>
|
||||||
<figcaption>#{@caption}</figcaption>
|
<figcaption>#{@caption}</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
EOF
|
EOF
|
||||||
|
|
23
_plugins/details_tag.rb
Normal file
23
_plugins/details_tag.rb
Normal file
|
@ -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))
|
||||||
|
"<details><summary>#{caption}</summary>#{body}</details>"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Liquid::Template.register_tag('details', Jekyll::Tags::DetailsTag)
|
Loading…
Reference in New Issue
Block a user