PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
266 stars 208 forks source link

Make an offline HTML version #444

Open rbeezer opened 7 years ago

rbeezer commented 7 years ago

It would be nice to somehow pack everything up so that an HTML version could run offline with very few compromises. Static Sage cells perhaps, but I think a local, stripped-down MathJax is not unusual.

Starting this as a place to park ideas.

rbeezer commented 7 years ago

On the mathbook-xml-support list Brian Walton said:

Some of this might be resolved by using a webapp manifest cache. That is the mechanism by which webapps can be stored in a browser or mobile device for access while offline.

https://www.html5rocks.com/en/tutorials/appcache/beginner/

I imagine the xsl could be worked to create a master list of all files in the book to create the manifest file. This would include all relevant files, including the CSS and javascript files. There might be some issues with caching all of the resources needed by MathJax, but I think it should still work offline. The biggest challenge is that if a site uses externally controlled files (e.g., CSS or javascript), the AppCache will not look for any changes unless the manifest file itself is changed.

It appears that AppCache is being deprecated in favor of a more flexible Service Workers architecture. I do not know if this would resolve the question about maintaining the most-up-to-date externally maintained files in the cache.

pkra commented 7 years ago

This might be helpful: https://github.com/pkra/MathJax-single-file. It can easily be cached via either AppCache or ServiceWorkers. Caching while using MathJax's usual dynamic resource loading is probably only possible via ServiceWorker.

Another alternative would be to use mathjax-node.

rbeezer commented 7 years ago

Thanks very much for the pointer, Peter. I had a vague recollection something like this was out there.

Rob

rbeezer commented 2 years ago

@siefkenj suggests MathJax could be bundled with React code.

StevenClontz commented 1 year ago

Generally, a switch to any JS framework will involve a "bundler", which slurps up all your JS and CSS dependencies into single "bundle.js" and "bundle.css" files. See https://github.com/StevenClontz/checkit/blob/main/docs/demo/assets/index.12c421f5.js and https://github.com/StevenClontz/checkit/blob/main/docs/demo/assets/index.616cf5cd.css for CheckIt's example.