From: Silvio Rhatto Date: Thu, 4 Mar 2021 18:29:27 +0000 (-0300) Subject: Feat: MathJax setup X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=d7ebfdb85cf73c027fb928518004533e428f3893;p=blog.git Feat: MathJax setup --- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..46a8d54 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "vendor/ikiwiki-plugin-mathjax"] + path = vendor/ikiwiki-plugin-mathjax + url = https://github.com/bk/ikiwiki-plugin-mathjax +[submodule "vendor/MathJax"] + path = vendor/MathJax + url = https://github.com/mathjax/MathJax.git diff --git a/local.css b/assets/css/local.css similarity index 100% rename from local.css rename to assets/css/local.css diff --git a/ikiwiki.yaml b/ikiwiki.yaml index 4780ec4..3467f1e 100644 --- a/ikiwiki.yaml +++ b/ikiwiki.yaml @@ -1,10 +1,10 @@ # IkiWiki::Setup::Yaml - YAML formatted setup file # # Setup file for ikiwiki. -# +# # Passing this to ikiwiki --setup will make ikiwiki generate # wrappers and build the wiki. -# +# # Remember to re-run ikiwiki --setup any time you edit this file. # # name of the wiki @@ -44,6 +44,7 @@ add_plugins: - sidebar - teximg - favicon +- mathjax # plugins to disable disable_plugins: - openid @@ -90,7 +91,7 @@ umask: 2 # group for wrappers to run in #wrappergroup: ikiwiki # extra library and plugin directory -libdir: '' +libdir: 'lib' # environment variables ENV: {} # time zone name @@ -212,6 +213,7 @@ pingurl: [] # mdwn plugin # enable multimarkdown features? #multimarkdown: 0 +multimarkdown: 1 # disable use of markdown discount? #nodiscount: 0 diff --git a/lib/IkiWiki/Plugin/mathjax.pm b/lib/IkiWiki/Plugin/mathjax.pm new file mode 100755 index 0000000..99b74c3 --- /dev/null +++ b/lib/IkiWiki/Plugin/mathjax.pm @@ -0,0 +1,74 @@ +package IkiWiki::Plugin::mathjax; + +use warnings; +use strict; +use IkiWiki 3.00; +use MIME::Base64; + +# Strategy: +## - filter replaces normal TeX delimiters with imath and dmath directives +## (perhaps while considering a mathconf directive); also, it adds a script +## block if there is any math on the page relevant. +## - preprocess handles the directives themselves. +## +## Later: config hooks for mathjax script tag and mathjax config block +## + +sub import { + hook(type => "filter", id => "mathjax", call => \&filter); + hook(type => "format", id=>"mathjax", call=> \&format); +} + +sub format { + my %params = @_; + my $content = $params{content}; + return $content unless $content =~ /\!\!mathjaxbegin/; #]/{{ + $content =~ s{\!\!mathjaxbegin-i!! (.*?)\s\!\!mathjaxend-i\!\!}{'\('.decode_base64($1).'\)'}ges; #{ + $content =~ s{\!\!mathjaxbegin-d!! (.*?)\s\!\!mathjaxend-d\!\!}{'\['.decode_base64($1).'\]'}ges; #{ + my $scripttag = _scripttag(); + $content =~ s{()}{$scripttag\n$1}i; #}{ + return $content; +} + +sub filter (@) { + my %params=@_; + my $content = $params{content}; + return $content unless $content =~ /\$[^\$]+\$|\\[\(\[][\s\S]+\\[\)\]]/; + # first, handle display math... + $content =~ s{(?/>/g; #{" + $directive .= encode_base64($formula, " "); + $directive .= "!!mathjaxend-$mode!!"; + return $directive; +} + +sub _scripttag { + my $config = 'TeX-AMS_HTML'; # another possibility: TeX-AMS-MML_HTMLorMML + return '' + . ''; +} + +1; diff --git a/meta.md b/meta.md index cbd6bb1..a11ed32 100644 --- a/meta.md +++ b/meta.md @@ -33,7 +33,7 @@ See [keys](/keys). ### Technology -* This is a [statically-generated website](/static). +* This is a [statically-generated website](/research/suckless/sites). * That tries to implement [IndieWebCamp principles](http://indiewebcamp.com/principles).