Skip to content

Commit

Permalink
added previews make target which uses NPM package usus and a loca…
Browse files Browse the repository at this point in the history
…l installed Chrome browser to render the demo/test pages to static HTML. This produces much better output (IMHO) than the `mathjax_node` package.
  • Loading branch information
GerHobbelt committed Oct 3, 2018
1 parent 2cb1961 commit fcc3104
Show file tree
Hide file tree
Showing 4 changed files with 1,015 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ help:
@echo "make prettier"
@echo " Run MathJax prettifier, which pretty-prints the combined library files"
@echo ""
@echo "make previews"
@echo " Render all MathJax demo pages in test/ to static HTML using usus+Chrome"
@echo ""
@echo "make all"
@echo " Regenerate the MathJax library files (pack, combine & prettify)"
@echo ""
Expand Down Expand Up @@ -85,6 +88,9 @@ fix:

prettier:
node globber/glob4prettier.js $(MATHJAXDIR)/mathjax/ | xargs prettier --write --print-width 120 --loglevel log

previews:
cd MkPreviews; bash ./generate-previews.sh ../$(MATHJAXDIR)/mathjax

misc: operator-dictionary MML-entities

Expand All @@ -102,5 +108,5 @@ clean-destination: config
# this assumes MATHJAXDIR is a *relative path* for the perl tools in combiner and packer:
-rm -rf $(MATHJAXDIR)/mathjax/config/ $(MATHJAXDIR)/mathjax/localization/ $(MATHJAXDIR)/mathjax/extensions/ $(MATHJAXDIR)/mathjax/jax/

.PHONY: help lint fix fonts pack combine clean clean-destination prettier misc operator-dictionary MML-entities all
.PHONY: help lint fix fonts pack combine clean clean-destination prettier previews misc operator-dictionary MML-entities all

47 changes: 47 additions & 0 deletions MkPreviews/generate-previews.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /bin/bash
#
# Generate static HTML preview pages for every demo page.
#
# NOTE/WARNING: this script should be executed from the Makefile, which in turn
# is invoked through `npm run previews` or eqv. command, so that the NODE SEARCH PATH
# includes the local node_modules/ directory and `usus` will be found there!
#



if test -d "$1" ; then cd "$1" ; else
echo <<EOT
generate-previews.sh MATHJAXBASEPATH
Error: missing BASEPATH argument.
EOT
exit 1
fi



if test -d ./test/ ; then cd ./test/ ; else
echo <<EOT
generate-previews.sh MATHJAXBASEPATH
Error: BASEPATH argument must point at the MathJax repository BASE PATH,
which is expected to contain a /test/ directory, among others...
EOT
exit 1
fi



mkdir -p StaticPreviewPages

for f in *.html ; do
# detect platform and call cygpath only where applicable:
if $( cygpath -w -a . &> /dev/null ) ; then
# Windows OS/cygwin/MingW/Wingit dev platform:
usus render --url file://$( cygpath -w -a ./$f ) > StaticPreviewPages/$f
else
# Linux et al:
usus render --url file://$( realpath ./$f ) > StaticPreviewPages/$f
fi
done

Loading

0 comments on commit fcc3104

Please sign in to comment.