projects
/
zzz-pokedex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9cd3849
)
Make rst as_html handle errors a little more nicely.
author
Eevee
<git@veekun.com>
Sun, 14 Mar 2010 02:11:40 +0000
(18:11 -0800)
committer
Eevee
<git@veekun.com>
Mon, 15 Mar 2010 07:10:08 +0000
(
00:10
-0700)
pokedex/db/rst.py
patch
|
blob
|
history
diff --git
a/pokedex/db/rst.py
b/pokedex/db/rst.py
index
80ac87e
..
a77feef
100644
(file)
--- a/
pokedex/db/rst.py
+++ b/
pokedex/db/rst.py
@@
-33,6
+33,8
@@
are, apparently, global.
return a reST node.
"""
return a reST node.
"""
+import cgi
+
from docutils.frontend import OptionParser
from docutils.io import Output
import docutils.nodes
from docutils.frontend import OptionParser
from docutils.io import Output
import docutils.nodes
@@
-131,8
+133,17
@@
class RstString(object):
"""Returns the string as HTML4."""
document = self.rest_document
"""Returns the string as HTML4."""
document = self.rest_document
- destination = UnicodeOutput()
+ # Check for errors; don't want to leave the default error message cruft
+ # in here
+ if document.next_node(condition=docutils.nodes.system_message):
+ # Boo! Cruft.
+ return u"""
+ <p><em>Error in markup! Raw source is below.</em></p>
+ <pre>{0}</pre>
+ """.format( cgi.escape(self.source_text) )
+
+ destination = UnicodeOutput()
writer = HTMLFragmentWriter()
return writer.write(document, destination)
writer = HTMLFragmentWriter()
return writer.write(document, destination)