X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/1f0d231daf5b121dce85da6658b36d5ead980104..e8a88a71dc6ad2ae6d18a810f627d50ec97cc62c:/pokedex/db/rst.py diff --git a/pokedex/db/rst.py b/pokedex/db/rst.py index d3d6322..a77feef 100644 --- a/pokedex/db/rst.py +++ b/pokedex/db/rst.py @@ -33,6 +33,8 @@ are, apparently, global. return a reST node. """ +import cgi + from docutils.frontend import OptionParser from docutils.io import Output import docutils.nodes @@ -87,7 +89,7 @@ roles.register_local_role('data', data_role) class RstString(object): """Wraps a reStructuredText string. Stringifies to the original text, but - may be translated to HTML with .to_html(). + may be translated to HTML with .as_html(). """ def __init__(self, source_text, document_properties={}): @@ -131,8 +133,17 @@ class RstString(object): """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""" +
Error in markup! Raw source is below.
+{0}+ """.format( cgi.escape(self.source_text) ) + + destination = UnicodeOutput() writer = HTMLFragmentWriter() return writer.write(document, destination)