[Checkins] SVN: zope.app.renderer/trunk/ Simplify reST renderer and adapt the whole thing to docutils 0.5 that is now required.
Dan Korostelev
nadako at gmail.com
Tue Jan 13 09:39:07 EST 2009
Log message for revision 94724:
Simplify reST renderer and adapt the whole thing to docutils 0.5 that is now required.
Changed:
U zope.app.renderer/trunk/CHANGES.txt
U zope.app.renderer/trunk/setup.py
U zope.app.renderer/trunk/src/zope/app/renderer/rest.py
-=-
Modified: zope.app.renderer/trunk/CHANGES.txt
===================================================================
--- zope.app.renderer/trunk/CHANGES.txt 2009-01-13 13:41:01 UTC (rev 94723)
+++ zope.app.renderer/trunk/CHANGES.txt 2009-01-13 14:39:07 UTC (rev 94724)
@@ -2,10 +2,14 @@
CHANGES
=======
-3.4.1 (unreleased)
+3.5.0 (unreleased)
------------------
-- Fix reST rendering with docutils 0.5.
+- Adapted to docutils 0.5 for ReST rendering: get rid of the
+ ZopeTranslator class, because docutils changed the way it
+ uses translator so previous implementation doesn't work anymore.
+ Instead, use publish_parts and join needed parts in the ``render``
+ method of the renderer itself.
3.4.0 (2007-10-27)
------------------
Modified: zope.app.renderer/trunk/setup.py
===================================================================
--- zope.app.renderer/trunk/setup.py 2009-01-13 13:41:01 UTC (rev 94723)
+++ zope.app.renderer/trunk/setup.py 2009-01-13 14:39:07 UTC (rev 94724)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.app.renderer',
- version = '3.4.1dev',
+ version = '3.5.0dev',
author='Zope Corporation and Contributors',
author_email='zope-dev at zope.org',
description='Text Renderer Framework',
@@ -49,7 +49,7 @@
namespace_packages=['zope', 'zope.app'],
extras_require = dict(test=['zope.app.testing']),
install_requires=['setuptools',
- 'docutils',
+ 'docutils>=0.5',
'zope.component',
'zope.configuration',
'zope.i18nmessageid',
Modified: zope.app.renderer/trunk/src/zope/app/renderer/rest.py
===================================================================
--- zope.app.renderer/trunk/src/zope/app/renderer/rest.py 2009-01-13 13:41:01 UTC (rev 94723)
+++ zope.app.renderer/trunk/src/zope/app/renderer/rest.py 2009-01-13 14:39:07 UTC (rev 94724)
@@ -18,8 +18,6 @@
__docformat__ = 'restructuredtext'
import docutils.core
-from docutils.writers.html4css1 import HTMLTranslator
-from docutils.writers.html4css1 import Writer
from zope.interface import implements
from zope.publisher.browser import BrowserView
@@ -39,26 +37,6 @@
IReStructuredTextSource, _("ReStructured Text (ReST)"),
_("ReStructured Text (ReST) Source"))
-
-class ZopeTranslator(HTMLTranslator):
- """
- The ZopeTranslator extends the base HTML processor for reST. It
- augments reST by:
-
- - Outputs *only* the 'body' parts of the document tree, using the
- internal docutils structure.
- """
-
- def astext(self):
- """
- This is where we join the document parts that we want in
- the output.
- """
- # use the title, subtitle, author, date, etc., plus the content
- body = self.body_pre_docinfo + self.docinfo + self.body
- return u"".join(body)
-
-
class ReStructuredTextToHTMLRenderer(BrowserView):
r"""An Adapter to convert from Restructured Text to HTML.
@@ -124,11 +102,9 @@
'initial_header_level': 3,
}
overrides.update(settings_overrides)
- writer = Writer()
- writer.translator_class = ZopeTranslator
- html = docutils.core.publish_parts(
+ parts = docutils.core.publish_parts(
self.context,
- writer=writer,
+ writer_name='html',
settings_overrides=overrides,
- )['body']
- return html
+ )
+ return u''.join((parts['body_pre_docinfo'], parts['docinfo'], parts['body']))
More information about the Checkins
mailing list