changeset 2263:c1682ea7ed8c

text_moin_wiki: fixed an other nesting {{{ }}} problem and added a new test
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 27 Jun 2007 21:21:04 +0200
parents ec8d3c66ad0c
children b0031a34f96d
files MoinMoin/_tests/parser/test_text_moin_wiki.py MoinMoin/parser/text_moin_wiki.py
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/parser/test_text_moin_wiki.py	Wed Jun 27 10:20:23 2007 +0200
+++ b/MoinMoin/_tests/parser/test_text_moin_wiki.py	Wed Jun 27 21:21:04 2007 +0200
@@ -548,4 +548,19 @@
         expected = True
 
         assert expected == result
- 
+
+    def testManyNestingPreBrackets(self):
+        """ tests two nestings  ({{{ }}} and {{{ }}}) in one line for the wiki parser 
+        """
+
+        raw = """{{{
+Test {{{brackets}}} and test {{{brackets}}}
+}}}"""
+        output = self.parse(raw)
+        output = ''.join(output)
+        result = '</span><p><pre>Test {{{brackets}}} and test {{{brackets}}}' in output
+        expected = True
+
+        assert expected == result
+
+
--- a/MoinMoin/parser/text_moin_wiki.py	Wed Jun 27 10:20:23 2007 +0200
+++ b/MoinMoin/parser/text_moin_wiki.py	Wed Jun 27 21:21:04 2007 +0200
@@ -884,6 +884,8 @@
         ###result.append(u'<span class="info">[scan: <tt>"%s"</tt>]</span>' % line)
         if line.count('{{{') > 1: 
             self.in_nested_pre = line.count('{{{') -  line.count('}}}')
+            if self.in_nested_pre == 0:
+                self.in_nested_pre = 1
             if line.startswith('{{{'):
                 line = line[3:].strip()
             self.in_pre = 'no_parser'
@@ -1032,9 +1034,10 @@
                         self.parser_name = parser_name
                         continue
                     else:
-                        self.request.write(self._closeP() +
-                                           self.formatter.preformatted(1))
-                        self.in_pre = 'no_parser'
+                         if not line.count('{{{') > 1:
+                             self.request.write(self._closeP() +
+                                 self.formatter.preformatted(1))
+                         self.in_pre = 'no_parser'
 
                 if self.in_pre == 'found_parser':
                     self.in_nested_pre += line.count('{{{')
@@ -1159,6 +1162,7 @@
             self.request.write(formatted_line)
             if self.in_pre == 'no_parser':
                 self.request.write(self.formatter.linebreak())
+                
 
         # Close code displays, paragraphs, tables and open lists
         self.request.write(self._undent())