Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Ball <cjb@laptop.org>2008-05-27 21:06:53 (GMT)
committer Chris Ball <cjb@laptop.org>2008-05-27 21:06:53 (GMT)
commit879b40d37024564eb8523ef6104848d84bee9bd4 (patch)
tree5067c3ee835a5d1ea0338bd7fea9ed8b14722e98
parentad276fa644e4517b1f7657668ac3ac28feddddf7 (diff)
parenteedf94eda384ebb413aaa90f7443bdae86db558e (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/projects/wikiserver
-rwxr-xr-xserver.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/server.py b/server.py
index a8759ba..9954da9 100755
--- a/server.py
+++ b/server.py
@@ -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