From 28407333ffceca9b99fae721c30e8ae146a863da Mon Sep 17 00:00:00 2001 From: Justin Gassner Date: Wed, 14 Feb 2024 07:24:38 +0100 Subject: Update --- _plugins/enunciation.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to '_plugins/enunciation.rb') 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 -- cgit v1.2.3-54-g00ecf