changeset 4718:634ed3db8df4

creole parser: Add second license: BSD, fix spaces in multiline elements. Because the parser eats line endings, multi-line elements such as paragraphs were adding an extra space at the end of each line, so that the lines were not glued together. This resulted in gratuitous spaces just before closing tags of pragraphs. In addtion, multiline list elements didn't add the extra spaces at all, so the lines *were* glued together. This bugfix makes the parser add spaces only between lines in all multi-line elements. One test case that relied on the added space just before closing tag was also fixed.
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 29 Apr 2009 22:10:47 +0200
parents 45fef2367628
children f976af4e61f1
files MoinMoin/parser/_creole.py MoinMoin/parser/_tests/test_text_creole.py
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/_creole.py	Tue Apr 28 00:07:21 2009 +0200
+++ b/MoinMoin/parser/_creole.py	Wed Apr 29 22:10:47 2009 +0200
@@ -19,6 +19,7 @@
     @copyright: 2007 MoinMoin:RadomirDopieralski (creole 0.5 implementation),
                 2007 MoinMoin:ThomasWaldmann (updates)
     @license: GNU GPL, see COPYING for details.
+    @license: BSD, see COPYING for details.
 """
 
 import re
@@ -258,13 +259,16 @@
     _head_text_repl = _head_repl
 
     def _text_repl(self, groups):
+        text = groups.get('text', '')
         if self.cur.kind in ('table', 'table_row', 'bullet_list',
             'number_list'):
             self.cur = self._upto(self.cur,
                 ('document', 'section', 'blockquote'))
         if self.cur.kind in ('document', 'section', 'blockquote'):
             self.cur = DocNode('paragraph', self.cur)
-        self.parse_inline(groups.get('text', '')+' ')
+        else:
+            text = u' ' + text
+        self.parse_inline(text)
         if groups.get('break') and self.cur.kind in ('paragraph',
             'emphasis', 'strong', 'code'):
             DocNode('break', self.cur, '')
@@ -280,6 +284,7 @@
         tb = self.cur
         tr = DocNode('table_row', tb)
 
+        text = ''
         for m in self.cell_re.finditer(row):
             cell = m.group('cell')
             if cell:
@@ -310,7 +315,6 @@
 
     def _line_repl(self, groups):
         self.cur = self._upto(self.cur, ('document', 'section', 'blockquote'))
-        self.text = None
 
     def _code_repl(self, groups):
         DocNode('code', self.cur, groups.get('code_text', u'').strip())
@@ -388,3 +392,5 @@
         self.content = content
         if self.parent is not None:
             self.parent.children.append(self)
+
+
--- a/MoinMoin/parser/_tests/test_text_creole.py	Tue Apr 28 00:07:21 2009 +0200
+++ b/MoinMoin/parser/_tests/test_text_creole.py	Wed Apr 29 22:10:47 2009 +0200
@@ -340,7 +340,7 @@
 }}}"""
         output = self.parse(raw)
         output = ''.join(output)
-        assert 'Example </p><pre>You can use {{{brackets}}}</pre>' in output
+        assert 'Example</p><pre>You can use {{{brackets}}}</pre>' in output
 
     def testManyNestingPreBrackets(self):
         """ tests two nestings  ({{{ }}} and {{{ }}}) in one line for the wiki parser