[英]How to use Mathjax in android, offline
I saw this post 我看到了这个帖子
http://cs.jsu.edu/wordpress/?p=498 http://cs.jsu.edu/wordpress/?p=498
and I tried using mathjax in offline 我尝试离线使用mathjax
I just want to include this code in my html 我只想将此代码包含在我的html中
w.loadDataWithBaseURL("http://bar/", "<script type='text/x-mathjax-config'>" +"MathJax.Hub.Config({ " +"showMathMenu: false, " +"jax: ['input/TeX','output/HTML-CSS'], " // output/SVG +"extensions: ['tex2jax.js','toMathML.js'], " +"TeX: { extensions: ['AMSmath.js','AMSsymbols.js'," +"'noErrors.js','noUndefined.js'] }, " //+"'SVG' : { blacker: 30, " // +"styles: { path: { 'shape-rendering': 'crispEdges' } } } " +"});</script>" +"<script type='text/javascript' " +"src='file:///android_asset/MathJax/MathJax.js'" +"></script>" +"<script type='text/javascript'>getLiteralMML = function() {" +"math=MathJax.Hub.getAllJax('math')[0];" // below, toMathML() rerurns literal MathML string +"mml=math.root.toMathML(''); return mml;" +"}; getEscapedMML = function() {" +"math=MathJax.Hub.getAllJax('math')[0];" // below, toMathMLquote() applies &-escaping to MathML string input +"mml=math.root.toMathMLquote(getLiteralMML()); return mml;}" +"</script>" +"<span id='math'></span><pre><span id='mmlout'></span></pre>","text/html","utf-8","");
i tried many times but didn't work. 我尝试了很多次,但是没有工作。
i tried this html 我试过这个HTML
<script type='text/x-mathjax-config'>
MathJax.Hub.Config({
showMathMenu: false,
jax: ['input/TeX','output/HTML-CSS'], // output/SVG
extensions: ['tex2jax.js','toMathML.js'],
TeX: { extensions: ['AMSmath.js','AMSsymbols.js',
'noErrors.js','noUndefined.js'] }, "
'SVG' : { blacker: 30,
styles: { path: { 'shape-rendering': 'crispEdges' } } }
});</script>
<script type='text/javascript'
src='file:///android_asset/MathJax/MathJax.js'
></script>"
<script type='text/javascript'>getLiteralMML = function() {
math=MathJax.Hub.getAllJax('math')[0];
// below, toMathML() rerurns literal MathML string
mml=math.root.toMathML(''); return mml;
}; getEscapedMML = function() {
math=MathJax.Hub.getAllJax('math')[0];
mml=math.root.toMathMLquote(getLiteralMML()); return mml;}
</script>
<span id='math'></span><pre><span id='mmlout'></span></pre>
I am not good at html help me please 我不擅长html请帮我
Wait for page to load before setting text. 等待页面加载,然后再设置文本。
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
question_webview.loadUrl("javascript:document.getElementById('mmlout').innerHTML='';");
question_webview.loadUrl("javascript:document.getElementById('math').innerHTML='\\\\["
+text.getText()+"\\\\]';");
question_webview.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
//question_webview.loadUrl("javascript:document.getElementById('mmlout').style.fontSize='200%'");
//question_webview.loadUrl("javascript:document.getElementById('math').style.fontSize='200%'");
}
});
webview.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url) {
webview.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
}
});
and 和
webview.loadDataWithBaseURL("http://bar",
"<html><head>" +
" <meta name=\"viewport\" content=\"width=device-width, user-scalable=yes\" />" +
"</head>" +
"" +
"<body style=\"font-size:18px\" >" +
message+
"</br> " +
"<script type=\"text/x-mathjax-config\">" +
" MathJax.Hub.Config({\n" +
" CommonHTML: { linebreaks: { automatic: true },EqnChunk:(MathJax.Hub.Browser.isMobile?10:50) },displayAlign: \"left\",\n" +
" \"HTML-CSS\": { linebreaks: { automatic: true } ," +
"\n" +
" preferredFont: \"STIX\"}," +
"extensions: [\"tex2jax.js\"],messageStyle:\"none\"," +
"jax: [\"input/TeX\", \"input/MathML\",\"output/HTML-CSS\"]," +
"tex2jax: {inlineMath: [['$','$'],['\\\\(','\\\\)']]}" +
"});" +
"</script>" +
"<script type=\"text/javascript\" async src=\"file:///android_asset/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"></script>" +
"" +
"</body>" +
"</html>", "text/html", "utf-8", "");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.