问题描述
我有LaTeX格式的javascipt字符串.例如:\frac{y^2}{2}x-\frac{2}{\sqrt{y}}+2(x-y)^2
I have javascipt string in LaTeX format. For example:\frac{y^2}{2}x-\frac{2}{\sqrt{y}}+2(x-y)^2
我希望能够使用定义的变量对其进行评估.有人为此目的知道框架或库吗?我试图在Google和堆栈中找到它,但没有成功.
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.
如果您建议使用replace/eval
进行评估-请回答而不评估上面的示例.不要浪费你的力量=)
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.
推荐答案
我认为您需要掌握LaTeX语法,并使用PEGjs或Jison之类的工具为您要使用的子集创建解析器/评估器计划使用.
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.
这篇关于如何在JavaScript中评估LaTeX公式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!