我终于让jqMath在Android Studio中工作了,但后来我意识到它不能正确地格式化\text和\table!https://mathscribe.com/author/jqmath.html在上面的jqMath主页上,示例展示了如何使用\text和\table。
在我的项目中,我使用这个字符串。
$$\text"Molarity" = \text"moles of solute" / \text"liters of solution"$$这是jqMath的代码。
WebView webView = new WebView(context);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
String path="file:///android_asset/";
String js = "<html><head>"
+ "<link rel='stylesheet' href='"+path+"jqmath-0.4.3.css'>"
+ "<script src='"+path+"jquery-1.4.3.min.js'></script>"
+ "<script src='"+path+"jqmath-etc-0.4.6.min.js'></script>"
+ "</head><body>"
+ "<script>var s = '"+formulaText+"';jqMath.parseMath(s);document.write(s);</script></body>";
webView.loadDataWithBaseURL( "file:///android_asset/", js, "text/html", "utf-8", null );这就是结果。
当我在主页上输入同样的东西时,它显示了this。
请帮助-我不知道为什么公式格式是有效的,但\text和\table以及所有\命令的格式都不正确!?!?
发布于 2019-07-10 06:20:50
好吧,所以,我最终自己找到了答案。问题不在jqMath!它是Android Studio的!Android Studio有一种奇怪的分析反斜杠的方式,所以我不得不将文本从
$$\text"Molarity" = \text"moles of solute" / \text"liters of solution"$$至
$\\\\text\\\"Molarity\\\" = \\\\text\\\"moles of solute\\\" / \\\\text\\\"liters of solution\\\"$这是因为Android Studio中的字符串似乎经历了自动反斜杠解析。因此,我之前的文本在经历jqMath格式之前被更改了。通过添加更多的反斜杠(每个反斜杠对应四个反斜杠),我可以将字符串转换为正确的字符串以通过jqMath!
https://stackoverflow.com/questions/56958169
复制相似问题