1

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

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

但我不明白如何使用它。例如,我想让它从命令行工作,这样我就可以给它一些数学公式并取回 mathMl 版本。我怎么能做到?有没有像这样的其他程序,可能是比 javascript 更少面向浏览器的语言?

4

1 回答 1

1

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>
于 2009-10-06T20:07:34.107 回答