I create a widget for displaying mathematical formulas using the KaTeX library. Faced with the problem of transfer of mathematical formulas.

WebView webView = new WebView(SpaceActivity.this); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); webView.setPadding(2, valueViewer.getTextPadding(), 2, valueViewer.getTextPadding()); String html = "<!DOCTYPE html>\n" + "<html>\n" + " <head>\n" + " <meta charset=\"UTF-8\">\n" + " <title>Auto-render test</title>\n" + " <link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_asset/katex/katex.min.css\">\n" + " <link rel=\"stylesheet\" type=\"text/css\" href=\"file:///android_asset/themes/style.css\">\n" + " <script type=\"text/javascript\" src=\"file:///android_asset/katex/katex.min.js\"></script>\n" + " <script type=\"text/javascript\" src=\"file:///android_asset/katex/contrib/auto-render.min.js\"></script>\n" + " </head>\n" + " <body>\n" + " " + expression + //строковая переменная, которой присваиваются различные формулы в TeX-формате " <script>\n" + " renderMathInElement(\n" + " document.body\n" + " );\n" + " </script>\n" + " </body>\n" + "</html>"; webView.getSettings().setSupportZoom(true); webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null); 

In the assets folder of the project is the KaTeX library v0.10.0.

Previously, I used the MathJax library, but it works slowly, and while drawing a new given formula, it flashes and jerks that it looks very bad.

Here there is a solution on JS, but it is not entirely clear where exactly it should be inserted:

https://github.com/KaTeX/KaTeX/issues/171#issuecomment-291391139

Tell me how you can set the automatic transfer of formulas.

    0