mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Make rst as_html handle errors a little more nicely.
This commit is contained in:
parent
c50697bd6b
commit
e0aeb771b2
1 changed files with 12 additions and 1 deletions
|
@ -33,6 +33,8 @@ are, apparently, global.
|
||||||
return a reST node.
|
return a reST node.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import cgi
|
||||||
|
|
||||||
from docutils.frontend import OptionParser
|
from docutils.frontend import OptionParser
|
||||||
from docutils.io import Output
|
from docutils.io import Output
|
||||||
import docutils.nodes
|
import docutils.nodes
|
||||||
|
@ -131,8 +133,17 @@ class RstString(object):
|
||||||
"""Returns the string as HTML4."""
|
"""Returns the string as HTML4."""
|
||||||
|
|
||||||
document = self.rest_document
|
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()
|
writer = HTMLFragmentWriter()
|
||||||
return writer.write(document, destination)
|
return writer.write(document, destination)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue