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 | |
parent | 777f9d3fd8caf56e6bc6999a4b05379307d0733f (diff) | |
download | site-28407333ffceca9b99fae721c30e8ae146a863da.tar.zst |
Update
Diffstat (limited to '_plugins')
-rw-r--r-- | _plugins/enunciation.rb | 23 | ||||
-rw-r--r-- | _plugins/example.rb | 12 | ||||
-rw-r--r-- | _plugins/proof.rb | 2 |
3 files changed, 28 insertions, 9 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 diff --git a/_plugins/example.rb b/_plugins/example.rb new file mode 100644 index 0000000..e149f23 --- /dev/null +++ b/_plugins/example.rb @@ -0,0 +1,12 @@ +module Jekyll + class ExampleTagBlock < Liquid::Block + + def render(context) + text = super + "<span style=\"text-transform: uppercase; font-weight: bold; font-size: .75em;\">Example</span> #{text}" + end + + end +end + +Liquid::Template.register_tag('example', Jekyll::ExampleTagBlock) diff --git a/_plugins/proof.rb b/_plugins/proof.rb index ab824e5..415b37f 100644 --- a/_plugins/proof.rb +++ b/_plugins/proof.rb @@ -3,7 +3,7 @@ module Jekyll def render(context) text = super - "<span style=\"text-transform: uppercase; font-weight: bold; font-size: .75em;\">Proof</span> #{text} <span style=\"float:right;\">$\\square\\enspace$</span>" + "<span style=\"text-transform: uppercase; font-weight: bold; font-size: .75em;\">Proof</span> #{text} <span style=\"float:right;\">$\\square\\enspace$</span>" end end |