diff options
author | Chris Ball <cjb@laptop.org> | 2008-05-27 21:06:53 (GMT) |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2008-05-27 21:06:53 (GMT) |
commit | 879b40d37024564eb8523ef6104848d84bee9bd4 (patch) | |
tree | 5067c3ee835a5d1ea0338bd7fea9ed8b14722e98 | |
parent | ad276fa644e4517b1f7657668ac3ac28feddddf7 (diff) | |
parent | eedf94eda384ebb413aaa90f7443bdae86db558e (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/projects/wikiserver
-rwxr-xr-x | server.py | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -153,18 +153,22 @@ class WPMathRenderer: #process = subprocess.Popen(('bin/itex2MML', '--inline'), stdin=subprocess.PIPE, stdout=subprocess.PIPE) process = subprocess.Popen(('bin/blahtex', '--mathml', '--texvc-compatible-commands'), stdin=subprocess.PIPE, stdout=subprocess.PIPE) - (mathml, err) = process.communicate(latex) + (mathml, err) = process.communicate(latex.encode('utf8')) if process.returncode is not 0: return "" # Ugly! There is certainly a better way to do this, but my DOM skills are weak, and this works. - dom = xml.dom.minidom.parseString(mathml) - dom = dom.getElementsByTagName('blahtex')[0] - dom = dom.getElementsByTagName('mathml')[0] - dom = dom.getElementsByTagName('markup')[0] - mathml = dom.toxml() - mathml = mathml.replace('markup', 'math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"') - dom.unlink() + try: + dom = xml.dom.minidom.parseString(mathml) + dom = dom.getElementsByTagName('blahtex')[0] + dom = dom.getElementsByTagName('mathml')[0] + dom = dom.getElementsByTagName('markup')[0] + mathml = dom.toxml() + mathml = mathml.replace('markup', 'math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"') + dom.unlink() + except: + print "BLAHTEX XML PARSING FAILED:\nINPUT: '%s'\nOUTPUT: '%s'" % (latex, mathml) + return "" # Straight embedding. Requires parent document to be XHTML. return mathml |