【问题标题】:Offline MathML rendring support in android appandroid 应用程序中的离线 MathML 渲染支持
【发布时间】:2016-02-20 08:06:33
【问题描述】:

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

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 在资产中。它可以正确呈现 Tex 输入,但我无法将其配置为将 MathML 作为输入并离线显示结果。

【问题讨论】:

  • 您可能想提供更多背景信息。至少一个链接到你正在使用的任何东西。
  • 我指的是cs.jsu.edu/wordpress/index.php/2012/08/01/…的代码它接受Tex输入并呈现输出。我想将 Mathml 作为输入并渲染输出。
  • Peter 的意思是您需要提供您正在使用的实际代码,而不是您为您的目的而修改的代码的链接(我们知道您必须修改它,因为您正在链接输入格式)。否则,我们几乎无法分析您的问题。

标签: android mathjax mathml


【解决方案1】:

要离线渲染 mathml,您需要将 MathJax 库添加到您的资产文件夹并使用 Web 视图配置该库

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]);");

【讨论】:

  • 非常感谢,我为此浪费了 24 小时。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多