问题描述
项目:我想用 PHP 构建一个 LaTeX 到 MathML 的翻译器.为什么?因为我是一名数学家,我想在我的 Drupal 网站上发布数学.它不必翻译所有的 LaTeX,因为基本的文档级别的东西可以由 CMS 处理,而且一开始就不会用 LaTeX 编写;它只需要将用 LaTeX 编写的数学转换为用 MathML 编写的数学.虽然我觉得我已经尽了我的职责,但这似乎并不存在.也许我错了——如果你知道可以达到这个目的的东西,一定要告诉我,并提前谢谢你.但是假设它不存在,我想我必须自己去写它.
The project: I want to build a LaTeX-to-MathML translator in PHP. Why? Because I'm a mathematician, and I want to publish math on my Drupal site. It doesn't have to translate all of LaTeX, since the basic document-level stuff is ably handled by the CMS and wouldn't be written in LaTeX to begin with; it just has to translate math written in LaTeX into math written in MathML. Although I feel as though I've done my due diligence, this doesn't seem to exist already. Maybe I'm wrong---if you know of something that would serve this purpose, by all means let me know, and thank you in advance. But assuming it doesn't exist, I guess I have to go write it myself.
但事情是这样的:我从来没有做过如此雄心勃勃的事情.我真的不知道从哪里开始.我已经使用 PHP 多年,但只是为了做标准的使用 PHP 和 MySQL 构建 CMS"类型的东西.我从来没有尝试过像从一种语言翻译成另一种语言这样看似复杂的事情.
Here's the thing, though: I've never done anything this ambitious. I don't really know where to begin. I've used PHP for years, but just to do the standard "build a CMS with PHP and MySQL"-type of stuff. I've never attempted anything as seemingly sophisticated as translation from one language to another.
我只是愚蠢到考虑用正则表达式来做——毕竟,LaTeX 是一种更正式的语言,它几乎不允许出现那种病态的边缘情况,比如 HTML.但另一方面,我很聪明地意识到这可能是一个糟糕的主意:现在我有两个问题,我当然不想像 这个人.
I'm just dumb enough to consider doing it with regex---after all, LaTeX is a much more formal language, and it doesn't allow for nearly the kinds of pathological edge-cases, as say, HTML. But on the other hand, I'm just smart enough to realize this is probably a terrible idea: now I have two problems, and I sure don't want to end up like this guy.
所以如果这不是要走的路(对吗?),那是什么?我应该如何开始思考这个问题?我是否本质上是在 PHP 中编写 LaTeX 编译器,如果是这样,我需要知道什么才能做到这一点(比如,我应该去阅读 紫龙书第一?)?
So if that's not the way to go (right?), what is? How should I start thinking about this problem? Am I essentially writing a LaTeX compiler in PHP, and if so, what do I need to know to do that (like, should I just go read the Purple Dragon book first?)?
我对这个项目的前景感到既兴奋又害怕,但是嘿,这就是我们学习成为程序员的方式,对吧?如果我们需要的东西不存在,我们就去建造它,必要性是……你明白了.非常感谢大家提前提供的任何和所有指导.
I'm both really excited and pretty intimidated by the prospect of this project, but hey, this is how we all learn to be programmers, right? If something we need doesn't exist, we go and build it, necessity is the mother of... you get the point. Tremendous thanks to everyone in advance for any and all guidance you can offer.
推荐答案
呃:
http://drupal.org/project/drutex
http://drupal.org/project/jsmath
http://www.forkosh.com/mimetex.html
这些有什么问题?
这篇关于基于 PHP 的 LaTeX 解析器——从哪里开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!