我将 MathJax 用于 Python/Google App Engine CRUD webapp。我希望人们使用 Content MathML 创建方程式(以便 webapp 可以利用其他地方的语义信息)。
然后我想使用这个 Content-to-Presentation MML XSLT,以便我可以在生成的 Presentation MathML 上使用 MathJax。
通常,我会做这样的事情来提供转换服务:
import lxml.etree as etree
class MathMLTranslator(object):
def __init__(self):
with open('ctop.xsl') as f:
self.xslt = etree.XSLT(etree.XML(f.read()))
def translate(self, xml_string):
return self.xslt(etree.XML(xml_string))
但我不能open('ctop.xsl')
在 Google App Engine 中做,也不能只是将 的内容ctop.xsl
作为字符串文字粘贴到 MathMLTranslator 中(它太大并且有两种类型的引号)。
我该如何处理?