mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 6c3cb43cf2e4d76d9282e857bbf5fbce5f620262
parent 90dfcc193b5c465f181bc613e3300acd47f19f34
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat, 20 Feb 2016 23:03:50 +0100

addmathjax

Diffstat:
addmathjax | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)

diff --git a/addmathjax b/addmathjax @@ -0,0 +1,31 @@ +#!/bin/bash + +TEMP=$(mktemp) + +# a3nm-mathjax-testing following a base debian image and included config +if ! docker ps | grep '\sa3nm-mathjax-testing$' > /dev/null +then + sudo docker run -di --name=a3nm-mathjax-testing \ + a3nm-mathjax-testing bash >/dev/null || { + echo "cannot start the mathjax container" >&2; exit 3; + } +fi + +cat > $TEMP + +if grep -E "class=\"math\"|class=\"tex\"" $TEMP > /dev/null +then + # expensive processing + TEMP2=$(mktemp) + sudo docker exec -i a3nm-mathjax-testing node_modules/mathjax-node/bin/page2html \ + --fontURL "https://mathjax.a3nm.net/fonts/HTML-CSS" <$TEMP >$TEMP2 || \ + { echo "cannot run mathjax" >&2; exit 2;} + sed 's,<style id="MathJax_CHTML_styles">undefined</style>,,g' "$TEMP2" | + sed 's,<span class="mjx-char"></span>,,g' + rm -f "$TEMP2" +else + cat "$TEMP" +fi + +rm -f "$TEMP" +