首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓应用中的离线MathML渲染支持

安卓应用中的离线MathML渲染支持
EN

Stack Overflow用户
提问于 2016-02-20 16:06:33
回答 1查看 1K关注 0票数 0

我想在安卓应用中离线渲染MathML。我正在使用MathJax来使用leathrum的APK。下面是设置mathjax离线配置(http://cs.jsu.edu/~leathrum/mjapp-src/full/MainActivity.java)的代码:

代码语言:javascript
复制
webview.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","");

本地Mathjax在assets.It中可以正确地呈现Tex输入,但我无法将其配置为将MathML作为输入并脱机显示结果。

EN

回答 1

Stack Overflow用户

发布于 2017-03-31 19:48:58

要使mathml脱机呈现,您需要将MathJax库添加到您的资产文件夹中,并使用web视图配置库

代码语言:javascript
复制
loadDataWithBaseURL("http://bar",
    "<html><head>" +
    " <meta name=\"viewport\" content=\"width=device-width, user-scalable=yes\" />" +
    "</head>" +
    "" +
    "<body style=\"font-size:18px\" >" +
    "<b>Put here your equation</b> </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", "");

loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35520689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档