Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
authorWade Brainerd <wadetb@gmail.com>2008-05-27 19:43:36 (GMT)
committer Wade Brainerd <wadetb@gmail.com>2008-05-27 19:43:36 (GMT)
commite5e84e643838000895e86285bb867763d54c21c7 (patch)
tree5b24c41ddc8dfe9dc00357dd33190cbe2f9c81b5 /server.py
parent220305a6d05647be7fb3e8d6324844c7e6438e4e (diff)
Add try/except to Blahtex XML parsing.
Diffstat (limited to 'server.py')
-rwxr-xr-xserver.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/server.py b/server.py
index a8759ba..163ef54 100755
--- a/server.py
+++ b/server.py
@@ -158,13 +158,17 @@ class WPMathRenderer:
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: '%s'" % mathml
+ return ""
# Straight embedding. Requires parent document to be XHTML.
return mathml