summaryrefslogtreecommitdiffstats
path: root/_plugins
diff options
context:
space:
mode:
authorJustin Gassner <justin.gassner@mailbox.org>2024-02-15 05:11:07 +0100
committerJustin Gassner <justin.gassner@mailbox.org>2024-02-15 05:11:07 +0100
commit7c66b227a494748e2a546fb85317accd00aebe53 (patch)
tree9c649667d2d024b90b32d36ca327ac4b2e7caeb2 /_plugins
parent28407333ffceca9b99fae721c30e8ae146a863da (diff)
downloadsite-7c66b227a494748e2a546fb85317accd00aebe53.tar.zst
Update
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/enunciation.rb22
-rw-r--r--_plugins/example.rb2
-rw-r--r--_plugins/proof.rb2
-rw-r--r--_plugins/singledollar.rb18
4 files changed, 19 insertions, 25 deletions
diff --git a/_plugins/enunciation.rb b/_plugins/enunciation.rb
index 3301e0d..b141ae9 100644
--- a/_plugins/enunciation.rb
+++ b/_plugins/enunciation.rb
@@ -1,39 +1,37 @@
module Jekyll
class EnunciationTagBlock < Liquid::Block
-
def initialize(tag_name, arg, parse_context)
super
@arg = arg.strip
- @slugtemplate = Liquid::Template.parse("{{ string | slugify }}")
+ @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[-5,5] == " $$\n"
+ if text[-5, 5] == " $$\n"
text += ' {: .katex-display .mb-0 }'
- elsif text[-3,3] == "$$\n"
+ 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!(/^/,'> ')}"
+ if @arg.empty?
+ "{: .#{block_name} }\n #{text.gsub!(/^/, '> ')}"
else
- if @arg[0] == "*"
- title = @arg.delete_prefix("* ")
+ 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!(/^/,'> ')}"
+ slug = @slugtemplate.render('string' => title)
+ "{: .#{block_name}-title }\n> #{title}\n> {: \##{slug} }\n>\n#{text.gsub!(/^/, '> ')}"
end
end
-
end
end
# TODO: avoid reading configuration twice
-Jekyll.configuration({})['callouts'].each do |name, value|
+Jekyll.configuration({})['callouts'].each do |name, _|
Liquid::Template.register_tag(name, Jekyll::EnunciationTagBlock)
end
diff --git a/_plugins/example.rb b/_plugins/example.rb
index e149f23..cdff2da 100644
--- a/_plugins/example.rb
+++ b/_plugins/example.rb
@@ -1,11 +1,9 @@
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
diff --git a/_plugins/proof.rb b/_plugins/proof.rb
index 415b37f..0c2b63b 100644
--- a/_plugins/proof.rb
+++ b/_plugins/proof.rb
@@ -1,11 +1,9 @@
module Jekyll
class ProofTagBlock < Liquid::Block
-
def render(context)
text = super
"<span style=\"text-transform: uppercase; font-weight: bold; font-size: .75em;\">Proof</span> &nbsp; #{text} <span style=\"float:right;\">$\\square\\enspace$</span>"
end
-
end
end
diff --git a/_plugins/singledollar.rb b/_plugins/singledollar.rb
index fe665ab..bb1f10c 100644
--- a/_plugins/singledollar.rb
+++ b/_plugins/singledollar.rb
@@ -4,16 +4,16 @@ require 'kramdown/parser/kramdown'
require 'kramdown-parser-gfm'
class Kramdown::Parser::GFMKatex < Kramdown::Parser::GFM
- # Override inline math parser
- @@parsers.delete(:inline_math)
+ # Override inline math parser
+ @@parsers.delete(:inline_math)
- INLINE_MATH_START = /(\$+)([^\$]+)(\$+)/m
+ INLINE_MATH_START = /(\$+)([^\$]+)(\$+)/m
- def parse_inline_math
- start_line_number = @src.current_line_number
- @src.pos += @src.matched_size
- @tree.children << Element.new(:math, @src.matched[1..-2], nil, category: :span, location: start_line_number)
- end
+ def parse_inline_math
+ start_line_number = @src.current_line_number
+ @src.pos += @src.matched_size
+ @tree.children << Element.new(:math, @src.matched[1..-2], nil, category: :span, location: start_line_number)
+ end
- define_parser(:inline_math, INLINE_MATH_START, '\$')
+ define_parser(:inline_math, INLINE_MATH_START, '\$')
end