“简单的数学语法”到 MathML 转换器

发布于 2024-08-07 19:19:03 字数 326 浏览 4 评论 0原文

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

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

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

I'd like something that converts a simple calculator like ascii math syntax to mathML.

I found this: http://www1.chapman.edu/~jipsen/mathml/asciimath.html

But I don't understand how to use it.. I'd like to make it work from the command line for example, so that I feed it some math formula and get back the mathMl version.
How could I do it? Is there any other program like this, maybe in a less browser oriented language than javascript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-08-14 19:19:03

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>∫</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>

Perl has Text::ASCIIMathML, which works quite well.

Adapted from the Synopsys section:

#!/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);

gives (reformatted for legibility):

<math>
  <mstyle>
    <mrow><msubsup><mo>∫</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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文