How to evaluate LaTeX formula in javascript?

纵然是瞬间 提交于 2019-12-10 23:19:24

问题


I have javascipt string in LaTeX format. For example: \frac{y^2}{2}x-\frac{2}{\sqrt{y}}+2(x-y)^2

I want to be able evaluate it with defined variables. Does anyone know framework or lib for this purpose? I've tried to find it in google and stack but without success.

If you suggest to evaluate it using replace/eval - please answer without evaluating example above. Do not waste your strength =)

Sorry, if I duplicate someone question - I will be grateful for link.


回答1:


I think you'd need to get hold of a LaTeX grammar and use a tool like PEGjs or Jison to create a parser/evaluator for the subset you're planning to use.



来源:https://stackoverflow.com/questions/16604660/how-to-evaluate-latex-formula-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!