ext/rest.py
branchstable
changeset 2312 af4d8f75c5db
parent 2311 f178182b1305
child 2467 6983631f5d0d
equal deleted inserted replaced
2311:f178182b1305 2312:af4d8f75c5db
    27 from docutils import statemachine, nodes, utils, io
    27 from docutils import statemachine, nodes, utils, io
    28 from docutils.core import publish_string
    28 from docutils.core import publish_string
    29 from docutils.parsers.rst import Parser, states, directives
    29 from docutils.parsers.rst import Parser, states, directives
    30 from docutils.parsers.rst.roles import register_canonical_role, set_classes
    30 from docutils.parsers.rst.roles import register_canonical_role, set_classes
    31 
    31 
    32 from logilab.mtconverter import ESC_UCAR_TABLE, ESC_CAR_TABLE, html_escape
    32 from logilab.mtconverter import ESC_UCAR_TABLE, ESC_CAR_TABLE, xml_escape
    33 
    33 
    34 from cubicweb.ext.html4zope import Writer
    34 from cubicweb.ext.html4zope import Writer
    35 
    35 
    36 # We provide our own parser as an attempt to get rid of
    36 # We provide our own parser as an attempt to get rid of
    37 # state machine reinstanciation
    37 # state machine reinstanciation
   234                               settings_overrides=settings)
   234                               settings_overrides=settings)
   235     except Exception:
   235     except Exception:
   236         LOGGER.exception('error while publishing ReST text')
   236         LOGGER.exception('error while publishing ReST text')
   237         if not isinstance(data, unicode):
   237         if not isinstance(data, unicode):
   238             data = unicode(data, encoding, 'replace')
   238             data = unicode(data, encoding, 'replace')
   239         return html_escape(req._('error while publishing ReST text')
   239         return xml_escape(req._('error while publishing ReST text')
   240                            + '\n\n' + data)
   240                            + '\n\n' + data)