From ab3784c5317f65e5ab8c9d366fce265e33aeb8f5 Mon Sep 17 00:00:00 2001 From: Rachel Lambda Samuelsson Date: Sun, 24 Dec 2023 22:44:07 +0100 Subject: [PATCH] add commutative diagram plugin --- _plugins/cd.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++ assets/css/main.scss | 13 ++++++++++ deps.nix | 2 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 _plugins/cd.rb diff --git a/_plugins/cd.rb b/_plugins/cd.rb new file mode 100644 index 0000000..149f9e2 --- /dev/null +++ b/_plugins/cd.rb @@ -0,0 +1,58 @@ +# Made by me :) +# Feel free to use if you give credit + +require "base64" + +module Jekyll + module Tags + class CDTag < Liquid::Block + + def initialize(tag_name, markup, tokens) + super + arr = markup.split("s:") + if arr[1] != nil + @scale = arr[1].to_i + else + @scale = 60 + end + @caption = arr[0].strip + end + + def render(context) + site = context.registers[:site] + + converter = site.find_converter_instance(::Jekyll::Converters::Markdown) + caption = converter.convert(@caption).gsub(/<\/?p[^>]*>/, '').chomp + + code = super(context) + + latex = < + A commutative diagram +
#{@caption}
+ +EOF + end + + "
#{caption}#{body}
" + end + + end + end +end + +Liquid::Template.register_tag('cd', Jekyll::Tags::CDTag) diff --git a/assets/css/main.scss b/assets/css/main.scss index a8888ae..8b24338 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -187,6 +187,19 @@ table { border-collapse: collapse; } +.cd { + display: block; + margin-left: auto; + margin-right: auto; + margin-bottom: 1em; + filter: invert(1); +} + +.cdfig { + margin-top: 2em; + margin-bottom: 2em; +} + // https://github.com/daveyarwood/gruvbox-pygments/tree/master .highlight .hll { background-color: #ffffcc } .highlight { background: #282828; color: #ebdbb2; background-color: #282828 } diff --git a/deps.nix b/deps.nix index 1345cb7..7cde034 100644 --- a/deps.nix +++ b/deps.nix @@ -124,4 +124,4 @@ with pkgs; let rouge ]); in -[ nodejs ] ++ rubyEnv.gems +[ nodejs inkscape scour ] ++ rubyEnv.gems