From fd0cbdb95ab29a805b5573b43d84e5a049f10f3b Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 8 Feb 2007 13:26:02 +0100 Subject: [PATCH] [svn r38140] Empty literal blocks are not allowed: removing them. --HG-- branch : trunk --- py/rest/rst.py | 5 ++++- py/rest/testing/test_rst.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/py/rest/rst.py b/py/rest/rst.py index 228402781..809fa3830 100644 --- a/py/rest/rst.py +++ b/py/rest/rst.py @@ -133,7 +133,8 @@ class Rest(AbstractNode): for child in self.children: outcome.append(child.text()) - text = self.sep.join(outcome) + "\n" # trailing newline + # always a trailing newline + text = self.sep.join([i for i in outcome if i]) + "\n" return text + self.render_links() class Transition(AbstractNode): @@ -251,6 +252,8 @@ class LiteralBlock(AbstractText): start = '::\n\n' def text(self): + if not self._text.strip(): + return '' text = self.escape(self._text).split('\n') for i, line in py.builtin.enumerate(text): if line.strip(): diff --git a/py/rest/testing/test_rst.py b/py/rest/testing/test_rst.py index f33d72ed4..9ff404738 100644 --- a/py/rest/testing/test_rst.py +++ b/py/rest/testing/test_rst.py @@ -175,6 +175,17 @@ Paragraph assert txt == expected checkrest(txt) +def test_blockquote_empty(): + expected = """\ +Foo + +Bar +""" + txt = Rest(Paragraph('Foo'), LiteralBlock(''), Paragraph('Bar')).text() + print repr(txt) + assert txt == expected + checkrest(txt) + def test_title(): txt = Title(Text("Some title"), belowchar="=").text() assert txt == "Some title\n=========="