diff options
author | Justin Gassner <justin.gassner@mailbox.org> | 2023-09-12 07:36:33 +0200 |
---|---|---|
committer | Justin Gassner <justin.gassner@mailbox.org> | 2024-01-13 20:41:27 +0100 |
commit | 777f9d3fd8caf56e6bc6999a4b05379307d0733f (patch) | |
tree | dc42d2ae9b4a8e7ee467f59e25c9e122e63f2e04 /_plugins/enunciation.rb | |
download | site-777f9d3fd8caf56e6bc6999a4b05379307d0733f.tar.zst |
Initial commit
Diffstat (limited to '_plugins/enunciation.rb')
-rw-r--r-- | _plugins/enunciation.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/_plugins/enunciation.rb b/_plugins/enunciation.rb new file mode 100644 index 0000000..75c777a --- /dev/null +++ b/_plugins/enunciation.rb @@ -0,0 +1,32 @@ +module Jekyll + class EnunciationTagBlock < Liquid::Block + + def initialize(tag_name, arg, parse_context) + super + @arg = arg.strip + end + + def render(context) + text = super + # If the enunciation ends with a KaTeX displayed equation, + # then we remove the bottom margin. + if text[-3,3] == "$$\n" + text += '{: .katex-display .mb-0 }' + end + # Check if a description was given. + if @arg.length < 1 + "{: .#{block_name} }\n #{text.gsub!(/^/,'> ')}" + else + "{: .#{block_name}-title }\n> #{block_name.capitalize} (#{@arg})\n>\n#{text.gsub!(/^/,'> ')}" + end + end + + end +end + +Liquid::Template.register_tag('definition', Jekyll::EnunciationTagBlock) +Liquid::Template.register_tag('theorem', Jekyll::EnunciationTagBlock) +Liquid::Template.register_tag('proposition', Jekyll::EnunciationTagBlock) +Liquid::Template.register_tag('lemma', Jekyll::EnunciationTagBlock) +Liquid::Template.register_tag('corollary', Jekyll::EnunciationTagBlock) +Liquid::Template.register_tag('axiom', Jekyll::EnunciationTagBlock) |