hplgit / doconce

Lightweight markup language - document once, include anywhere
http://hplgit.github.io/doconce/doc/web/index.html
Other
312 stars 60 forks source link

Updating MathJax CDN in HTML documents #116

Open KGHustad opened 7 years ago

KGHustad commented 7 years ago

The easiest way to update HTML documents to use the new MathJax CDN is to rerun doconce. However, in some circumstances, this may not be possible if the doconce source files have been lost.

A script which fixes the MathJax CDN in HTML documents have been written and tested with the DocOnce documentation. This script is available in utils/fix_mathjax_cdn.py in the repo and https://github.com/hplgit/doconce/blob/master/utils/fix_mathjax_cdn.py

Usage

Standalone

./fix_mathjax_cdn.py <html file>

With find

This script should be paired with find to fix all files in a given directory and its subdirectories.

Say we have the following directory structure

[cwd: doc]$ tree
.
├── fix_mathjax_cdn.py
├── pub
│   ├── book.html
│   ├── book.pdf
│   └── chapters
│       ├── chap1.html
│       ├── chap1.pdf
│       ├── chap2.html
│       ├── chap2.pdf
│       ├── chap3.html
│       └── chap3.pdf

We can use the following command

find . -type f -name '*.html' -exec ./fix_mathjax.py {} \;