diff options
author | Justin Gassner <justin.gassner@mailbox.org> | 2024-02-14 07:24:38 +0100 |
---|---|---|
committer | Justin Gassner <justin.gassner@mailbox.org> | 2024-02-14 07:24:38 +0100 |
commit | 28407333ffceca9b99fae721c30e8ae146a863da (patch) | |
tree | 67fa2b79d5c48b50d4e394858af79c88c1447e51 /_plugins/enunciation.rb | |
parent | 777f9d3fd8caf56e6bc6999a4b05379307d0733f (diff) | |
download | site-28407333ffceca9b99fae721c30e8ae146a863da.tar.zst |
Update
Diffstat (limited to '_plugins/enunciation.rb')
-rw-r--r-- | _plugins/enunciation.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/_plugins/enunciation.rb b/_plugins/enunciation.rb index 75c777a..3301e0d 100644 --- a/_plugins/enunciation.rb +++ b/_plugins/enunciation.rb @@ -4,29 +4,36 @@ module Jekyll def initialize(tag_name, arg, parse_context) super @arg = arg.strip + @slugtemplate = Liquid::Template.parse("{{ string | slugify }}") 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" + if text[-5,5] == " $$\n" + text += ' {: .katex-display .mb-0 }' + elsif 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!(/^/,'> ')}" + if @arg[0] == "*" + title = @arg.delete_prefix("* ") + else + title = "#{block_name.capitalize} (#{@arg})" + end + slug = @slugtemplate.render( 'string' => title ) + "{: .#{block_name}-title }\n> #{title}\n> {: \##{slug} }\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) +# TODO: avoid reading configuration twice +Jekyll.configuration({})['callouts'].each do |name, value| + Liquid::Template.register_tag(name, Jekyll::EnunciationTagBlock) +end |