现在我为Android编写程序。此应用程序必须使用MathJax 库将公式呈现给WebView。但我有问题......有时它不起作用(不时形成)......现在来源:
// This function calls everytime before output
public static void clearWebView()
{
w.loadDataWithBaseURL("http://bar", "<!DOCTYPE html><html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no\"> <script type='text/x-mathjax-config'>"
+"MathJax.Hub.Config({ "
+"showMathMenu: false, "
+"jax: ['input/TeX','output/HTML-CSS'], "
+"extensions: ['tex2jax.js'], "
+"TeX: { extensions: ['AMSmath.js','AMSsymbols.js',"
+"'noErrors.js','noUndefined.js', 'MathZoom.js'" +
"] } "
+"});</script>"
+"<script type='text/javascript' "
+"src=\"file:///android_asset/MathJax/MathJax.js\""
+"></script></head><body><span id='solve'></span></body></html>" ,"text/html","utf-8", "");
}
还有两个渲染函数:
public static void RenderHTML(String html)
{
w.loadUrl("javascript:document.getElementById('solve').innerHTML += '" + html + "';");
}
public static void RenderMath(String tex)
{
RenderHTML("\\\\[" + doubleEscapeTeX(tex) + "\\\\]");
w.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
}