问题描述
我正在尝试使用 webview 在 android 应用程序上呈现 MathJax。但是在呈现给定的 html 字符串后显示了意外的字符。
这是我的代码
public void renderHtml(WebView w,String data){
w.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
w.getSettings().setAppCacheEnabled(true);
String finalData = data;
w.loadDataWithBaseURL(null,mathJaxScript+"<span style=\" margin:0px; top:0px; \"><math display='inline-block'>"+data+"</math></span>","text/html","utf-8",null);
}
这是要呈现的 MathJax 配置。
public String mathJaxScript="<script type='text/javascript' "
+ "src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'"
+ "id=\"MathJax-script\" async"
+ "></script>"
+"<script type='text/x-mathjax-config'>"
+ "MathJax.Hub.Config({ "
+"skipStartupTypeset: false,"
+ "showMathMenu: false,"
+"tex2jax: { inlineMath: [[\"$\",\"$\"]],displayMath:[[\"$$\",\"$$\"]] },"
+"mtextFontInherit: true,"
+"CommonHTML: {scale: 100},"
+ "});" +
" \" MathJax.Hub.Register.StartupHook('End',() => {\\n\" +\n" +
" \" window.hubReady.next();\\n\" +\n" +
" \" window.hubReady.complete();\\n\" +\n" +
" \" });\\n\"" +
"</script>"
+ "<span id='math'></span>" ;
这是渲染后的输出
它在 Android 10 和 9 版本中运行良好,但无法在 android 7 中呈现。 如果您对如何解决此问题有任何想法,请告诉我。 提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)