gpt4 book ai didi

javascript - "simple math syntax"到 MathML 转换器

转载 作者:行者123 更新时间:2023-11-28 02:59:25 24 4
gpt4 key购买 nike

我想要将简单的计算器(如 ascii 数学语法)转换为 mathML 的东西。

我发现了这个:http://www1.chapman.edu/~jipsen/mathml/asciimath.html

但我不明白如何使用它.. 例如,我想让它从命令行工作,这样我就可以向它提供一些数学公式并返回 mathMl 版本。我怎样才能做到呢?是否还有其他类似的程序,可能是使用比 javascript 更不面向浏览器的语言?

最佳答案

Perl 有 Text::ASCIIMathML ,效果很好。

改编自 Synopsys 部分:

#!/usr/bin/perl

use strict;
use warning;
use Text::ASCIIMathML;

my $parser = Text::ASCIIMathML->new;

my $ASCIIMathML = "int_0^1 e^x dx";

print $parser->TextToMathML($ASCIIMathML);

给出(为了易读而重新格式化):

<math>
<mstyle>
<mrow><msubsup><mo>&#x222B;</mo><mn>0</mn><mn>1</mn></msubsup></mrow>
<msup><mi>e</mi><mi>x</mi></msup>
<mrow><mi>d</mi><mi>x</mi></mrow>
</mstyle>
</math>

关于javascript - "simple math syntax"到 MathML 转换器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1527762/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com