changeset 3990:645d031f4eab

fix gui editor remove nested markup problem
author Byeongweon [tasyblue@gmail.com]
date Fri, 01 Aug 2008 09:38:06 +0900
parents dd7446b5e95c
children 42c243588d64
files MoinMoin/converter/text_html_text_moin_wiki.py
diffstat 1 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Wed Jul 30 20:14:07 2008 +0900
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Fri Aug 01 09:38:06 2008 +0900
@@ -917,18 +917,30 @@
                 else:
                     pass
                     #print i.localName
-        else:
-            self.text.extend(["{{{", self.new_line])
+        else:
+            content_buffer = []
+            longest_inner_formater = ''
+
             for i in node.childNodes:
-                if i.nodeType == Node.TEXT_NODE:
-                    self.text.append(i.data)
+                if i.nodeType == Node.TEXT_NODE:
+                    # get longest pre tag({{{) from content
+                    longest_inner_formater = max([longest_inner_formater, max(re.compile("(?u){+").findall(i.data))])
+                    content_buffer.append(i.data)
                     #print "'%s'" % i.data
-                elif i.localName == 'br':
-                    self.text.append(self.new_line_dont_remove)
+                elif i.localName == 'br':
+                    content_buffer.append(self.new_line_dont_remove)
                 else:
                     pass
-                    #print i.localName
-            self.text.extend(["}}}", self.new_line])
+                    #print i.localName
+
+            if (len(longest_inner_formater) >= 3):
+                self.text.extend(["{" * (len(longest_inner_formater) + 1), self.new_line])
+                map(lambda item : self.text.append(item), content_buffer)
+                self.text.extend(["}" * (len(longest_inner_formater) + 1), self.new_line])
+            else:                
+                self.text.extend(["{{{", self.new_line])
+                map(lambda item : self.text.append(item), content_buffer)
+                self.text.extend(["}}}", self.new_line])
 
     _alignment = {"left": "(",
                   "center": ":",