changeset 1926:a1bebd238065

fix 314 correct rendering of comments with internal markup and mixed emphasis/strong markup
author Roger Haase <crosseyedpenguin@yahoo.com>
date Thu, 31 Jan 2013 07:28:39 -0700
parents b992bfbf70ae
children 62678298a3e6
files MoinMoin/converter/_tests/test_moinwiki_in.py MoinMoin/converter/_util.py MoinMoin/converter/moinwiki_in.py
diffstat 3 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/_tests/test_moinwiki_in.py	Thu Jan 31 07:25:12 2013 -0700
+++ b/MoinMoin/converter/_tests/test_moinwiki_in.py	Thu Jan 31 07:28:39 2013 -0700
@@ -81,6 +81,10 @@
                 '<page><body><p>Text <emphasis>Emphasis</emphasis></p><p>Text</p></body></page>'),
             ("Text''''''Text''''",
                 '<page><body><p>TextText</p></body></page>'),
+            ("''italic '''strongitalic ''''' normal",
+                '<page><body><p><emphasis>italic <strong>strongitalic </strong></emphasis> normal</p></body></page>'),
+            ("'''strong '''''italic '''strongitalic''''' normal",
+                '<page><body><p><strong>strong </strong><emphasis>italic <strong>strongitalic</strong></emphasis> normal</p></body></page>'),
         ]
         for i in data:
             yield (self.do, ) + i
@@ -119,6 +123,10 @@
                 '<page><body><p><span font-size="120%">larger</span></p></body></page>'),
             ("--(strike through)--",
                 '<page><body><p><span text-decoration="line-through">strike through</span></p></body></page>'),
+            ("normal ~+big __underline__ big+~ normal",
+                '<page><body><p>normal <span font-size="120%">big <span text-decoration="underline">underline</span> big</span> normal</p></body></page>'),
+            ("/* normal __underline__ normal */",
+                '<page><body><p><span class="comment">normal <span text-decoration="underline">underline</span> normal</span></p></body></page>'),
             (u'&quot;',
                 '<page><body><p>"</p></body></page>'),
             (u'&#34;',
--- a/MoinMoin/converter/_util.py	Thu Jan 31 07:25:12 2013 -0700
+++ b/MoinMoin/converter/_util.py	Thu Jan 31 07:28:39 2013 -0700
@@ -155,8 +155,9 @@
         if elem:
             self.top_append(elem)
 
-    def top_check(self, *names):
+    def top_check(self, *names, **kwargs):
         """
-        Checks if the name of the top of the stack matches the parameters.
+        Check if the top of the stack name and attrib matches the parameters.
         """
-        return self._list[-1].name in names
+        attrib = kwargs.get('attrib', {})
+        return self._list[-1].name in names and set(attrib.items()).issubset(self._list[-1].elem.attrib.items())
--- a/MoinMoin/converter/moinwiki_in.py	Thu Jan 31 07:25:12 2013 -0700
+++ b/MoinMoin/converter/moinwiki_in.py	Thu Jan 31 07:28:39 2013 -0700
@@ -533,10 +533,11 @@
                 else:
                     stack.push(moin_page.strong())
             elif stack.top_check('strong'):
-                if stack.top_check('strong'):
+                stack.pop()
+                if stack.top_check('emphasis'):
                     stack.pop()
                 else:
-                    stack.push(moin_page.strong())
+                    stack.push(moin_page.emphasis())
             else:
                 if len(emphstrong_follow) == 3:
                     stack.push(moin_page.emphasis())
@@ -654,11 +655,11 @@
     """
 
     def inline_underline_repl(self, stack, underline):
-        if not stack.top_check('span'):
-            attrib = {moin_page.text_decoration: 'underline'}
+        attrib = {moin_page.text_decoration: 'underline'}
+        if stack.top_check('span', attrib=attrib):
+            stack.pop()
+        else:
             stack.push(moin_page.span(attrib=attrib))
-        else:
-            stack.pop()
 
     inline_link = r"""
         (?P<link>