mathJax offline

1、

https://www.drupal.org/node/2420509

I got it. first download library from mathjax.org (https://github.com/mathjax/MathJax/archive/v2.6-latest.zip) , then unzip to libraries folder and rename folder to mathjax ( all small caps) and uncheck the cdn path in mathjax module configuration page.

 

2、

https://stackoverflow.com/questions/48867501/mathjax-offline-for-web-view?r=SearchResults

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.

Answer

file:///android_asset/MathJax/Found the solution. 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.

shareimprove this answer

edited Feb 21 '18 at 14:54

answered Feb 19 '18 at 15:11

Gaudam Thiyagarajan

560415

  • Its not working for me after using MathJax-grunt-cleaner. any idea? – Shahzad Akram Feb 11 at 14:57

  • you have to make sure you are removing only files that you don't need – Gaudam Thiyagarajan Feb 12 at 11:05

  • Sorry but I have zero experience with JavaScript, can you guide me about this? – Shahzad Akram Feb 12 at 11:09

  • 1

    basically you would have a config set on mathjax script loading location MathJax.Hub.Config. In the grunt file you can disable other configs that you dont need. for example Im using HTML-CSS as output so I don't need commonHtmlOutput, svgOutput, previewHtmlOutput, plainSourceOutput. So comment those out and then run the grunt file. Make sure you don't remove anything that you might need – Gaudam ThiyagarajanFeb 12 at 11:34 

add a comment

 

3、

https://docs.mathjax.org/en/latest/misc/mathjax-in-use.html?highlight=offline

https://pastebin.com/rBA40eq

How to make the source(path) of MathJax.js environment dependent?
<script src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js"></script>
<script>
if( !window.MathJax ) {
    document.write(
        '<script type="text/javascript" src="../lib/MathJax.js"></script>'
    );
}
</script>
	
<script>
var url= location.protocol == 'http:'? 
         "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js" :
         "../lib/MathJax.js";
document.write(
    '<script type="text/javascript" src="' + url + '"></script>'
);
</script>

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章