android
  • mathjax
  • mathml
  • 2016-02-20 45 views 0 likes 
    0

    我想在Android應用程序內呈現MathML離線。我使用MathJax使用leathrum的APK。下面是設置mathjax離線配置(http://cs.jsu.edu/~leathrum/mjapp-src/full/MainActivity.java)代碼:離線MathML在Android應用程序支持

    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正常顯示,特克斯輸入,但我不能將其配置到需要MATHML作爲輸入和顯示結果下線。

    +0

    您可能需要提供更多的背景庫。至少可以鏈接到你正在使用的任何東西。 –

    +0

    我指的代碼在http://cs.jsu.edu/wordpress/index.php/2012/08/01/standalone-mathjax-app-for-android/它需要Tex輸入和呈現輸出。我想將Mathml作爲輸入並渲染輸出。 – Gaurav

    +0

    Peter意味着你需要提供你正在使用的實際代碼,而不是你爲了你的目的而修改的代碼的鏈接(我們知道你必須修改它,因爲你鏈接的是輸入格式)。沒有這些,我們幾乎沒有辦法分析你的問題。 –

    回答

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

    非常感謝,我只是爲此而浪費了24小時。 – wonderPub

    相關問題