summaryrefslogtreecommitdiffstats
path: root/_plugins
diff options
context:
space:
mode:
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/enunciation.rb23
-rw-r--r--_plugins/example.rb12
-rw-r--r--_plugins/proof.rb2
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> &nbsp; #{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> &nbsp; #{text} <span style=\"float:right;\">$\\square\\enspace$</span>"
end
end