Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathjax offline for web view

Using webview to render math content by linking mathjax cdn for react native is common. But how to approach the problem of making it offline.

  1. Is there a way to locally maintain that bundle?

  2. Is it even prefered?

  3. What will be the size of the bundle ? I dont want my app size to go beyond 10mb.

like image 853
Gaudam Thiyagarajan Avatar asked Feb 19 '18 13:02

Gaudam Thiyagarajan


People also ask

Why is MathJax not working?

MathJax fails to load if the site is being viewed through HTTPS, which it is if HTTPS Everywhere. Disable HTTPS Everywhere for just this site, and then reload the page without HTTPS.

How can I download MathJax?

Obtaining MathJax via an archive Release versions of MathJax are available in archive files from the MathJax GitHub page. The current version is available via the “clone or download” button, or you can use the “releases” tab to download an archive for an older version.


1 Answers

Download your mathjax from

http://docs.mathjax.org/en/latest/installation.html

into => android/app/src/main/assets/

Now in your webview html code set script reference to

<script src="file:///android_asset/MathJax/MathJax.js?config=TeX-MML-AM_CHTML"></script>

and your necessary config inside html. Also make sure to set base url to your folder name.

<WebView source={{ html, baseUrl: 'file:///android_asset/MathJax/' }} />

Also you can https://github.com/mathjax/MathJax-grunt-cleaner to reduce the Mathjax asset size by removing unnecessary fonts and formats that you don't use.

like image 132
Gaudam Thiyagarajan Avatar answered Oct 16 '22 18:10

Gaudam Thiyagarajan