Commit 1a87da63 authored by Godefroid Chapelle's avatar Godefroid Chapelle

Collector #1770: Fixed RestructuredText subtitle

parent c895a9ab
...@@ -26,6 +26,8 @@ Zope Changes ...@@ -26,6 +26,8 @@ Zope Changes
Bugs Fixed Bugs Fixed
- Collector #1770: Fixed RestructuredText subtitle
- Collector #1803: Fixed InitializeClass for some corner case. - Collector #1803: Fixed InitializeClass for some corner case.
- Collector #1798, issue 1: ZopeTestCase no longer tries to - Collector #1798, issue 1: ZopeTestCase no longer tries to
......
...@@ -139,16 +139,25 @@ def HTML(src, ...@@ -139,16 +139,25 @@ def HTML(src,
'title': parts['title'], 'title': parts['title'],
} }
subheader = '<h%(level)s class="subtitle">%(subtitle)s</h%(level)s>\n' % {
'level': initial_header_level+1,
'subtitle': parts['subtitle'],
}
body = '%(docinfo)s%(body)s' % { body = '%(docinfo)s%(body)s' % {
'docinfo': parts['docinfo'], 'docinfo': parts['docinfo'],
'body': parts['body'], 'body': parts['body'],
} }
output = ''
if parts['title']: if parts['title']:
output = header + body output = output + header
else: if parts['subtitle']:
output = body output = output + subheader
output = output + body
warnings = ''.join(warning_stream.messages) warnings = ''.join(warning_stream.messages)
return output.encode(output_encoding) return output.encode(output_encoding)
......
import unittest import unittest
from reStructuredText import HTML
class TestReST(unittest.TestCase): class TestReST(unittest.TestCase):
...@@ -8,8 +7,21 @@ class TestReST(unittest.TestCase): ...@@ -8,8 +7,21 @@ class TestReST(unittest.TestCase):
# Make sure we can import the rst parser # Make sure we can import the rst parser
from docutils.parsers import rst from docutils.parsers import rst
def testWithSingleSubtitle(self):
input = '''
title
-----
subtitle
++++++++
text
'''
expected='''<h3 class="title">title</h3>
<h4 class="subtitle">subtitle</h4>
<p>text</p>
'''
output = HTML(input)
self.assertEquals(output, expected)
def test_suite(): def test_suite():
from unittest import TestSuite, makeSuite from unittest import TestSuite, makeSuite
return TestSuite((makeSuite(TestReST),)) return TestSuite((makeSuite(TestReST),))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment