[Zope-Checkins] CVS: Zope/lib/python/reStructuredText - __init__.py:1.7.2.5

Christian 'Tiran' Heimes heimes at faho.rwth-aachen.de
Sun May 23 01:52:03 EDT 2004


Update of /cvs-repository/Zope/lib/python/reStructuredText
In directory cvs.zope.org:/tmp/cvs-serv11665/lib/python/reStructuredText

Modified Files:
      Tag: Zope-2_7-branch
	__init__.py 
Log Message:
Fixed reST header


=== Zope/lib/python/reStructuredText/__init__.py 1.7.2.4 => 1.7.2.5 ===
--- Zope/lib/python/reStructuredText/__init__.py:1.7.2.4	Fri May 14 10:54:52 2004
+++ Zope/lib/python/reStructuredText/__init__.py	Sun May 23 01:52:01 2004
@@ -15,6 +15,19 @@
 This implementation requires docutils 0.3.4+ from http://docutils.sf.net/
 """
 
+try:
+    import docutils
+except ImportError:
+    raise ImportError, 'Please install docutils 0.3.3+ from http://docutils.sourceforge.net/#download.'
+
+version = docutils.__version__.split('.')
+if version < ['0', '3', '3']:
+    raise ImportError, """Old version of docutils found:
+Got: %(version)s, required: 0.3.3+
+Please remove docutils from %(path)s and replace it with a new version. You
+can download docutils at http://docutils.sourceforge.net/#download.
+""" % {'version' : docutils.__version__, 'path' : docutils.__path__[0] }
+
 import sys, os, locale
 from App.config import getConfiguration
 from docutils.core import publish_parts
@@ -60,7 +73,7 @@
     settings['stylesheet'] = stylesheet
     settings['language_code'] = language_code
     # starting level for <H> elements:
-    settings['initial_header_level'] = initial_header_level
+    settings['initial_header_level'] = initial_header_level + 1
     # set the reporting level to something sane:
     settings['report_level'] = report_level
     # don't break if we get errors:
@@ -119,17 +132,23 @@
                                    initial_header_level = initial_header_level,
                                    settings = settings)
 
-    output = ('<h%(level)s class="title">%(title)s</h%(level)s>\n'
-              '%(docinfo)s%(body)s' % {
+    header = '<h%(level)s class="title">%(title)s</h%(level)s>\n' % {
                   'level': initial_header_level,
                   'title': parts['title'],
+             }
+
+    body = '%(docinfo)s%(body)s' % {
                   'docinfo': parts['docinfo'],
-                  'body': parts['body']
-              }).encode(output_encoding)
+                  'body': parts['body'],
+             }
 
-    warnings = ''.join(warning_stream.messages)
+    if parts['title']:
+        output = header + body
+    else:
+        output = body
 
-    return output
+    warnings = ''.join(warning_stream.messages)
 
+    return output.encode(output_encoding)
 
 __all__ = ("HTML", 'render')




More information about the Zope-Checkins mailing list