changeset 560:b4eedd2147ff

gui converter: fix processing of complex list elements imported from: moin--main--1.5--patch-564
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 14 Apr 2006 10:03:29 +0000
parents 77e2149d7eab
children 3e3a4a38db1f
files ChangeLog MoinMoin/converter/text_html_text_x_moin.py
diffstat 2 files changed, 44 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Apr 14 09:44:16 2006 +0000
+++ b/ChangeLog	Fri Apr 14 10:03:29 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-04-14 11:03:29 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-564
+
+    Summary:
+      gui converter: fix processing of complex list elements
+    Revision:
+      moin--main--1.5--patch-564
+
+    gui converter: fix processing of complex list elements
+    
+
+    modified files:
+     ChangeLog MoinMoin/converter/text_html_text_x_moin.py
+
+
 2006-04-14 10:44:16 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-563
 
     Summary:
--- a/MoinMoin/converter/text_html_text_x_moin.py	Fri Apr 14 09:44:16 2006 +0000
+++ b/MoinMoin/converter/text_html_text_x_moin.py	Fri Apr 14 10:03:29 2006 +0000
@@ -633,19 +633,37 @@
     process_ul = process_list
     process_ol = process_list
 
+    def empty_paragraph_queue(self, nodelist, indent, need_indent):
+        if need_indent:
+            self.text.append(indent)
+        for i in nodelist:
+            if i.nodeType == Node.ELEMENT_NODE:
+                self.process_inline(i)
+            elif i.nodeType == Node.TEXT_NODE:
+                self.text.append(i.data.strip('\n').replace('\n', ' '))
+        self.text.append('\n')
+        del nodelist[:]
+
     def process_list_item(self, node, indent):
         found = False
-        first_child = True
+        need_indent = False
+
+        pending = []
         for i in node.childNodes:
             name = i.localName
+
+            if name in ('p', 'pre', 'ol', 'ul', 'dl', 'table',) and pending:
+                self.empty_paragraph_queue(pending, indent, need_indent)
+                need_indent = True
+                
             if name == 'p':
-                if not first_child:
+                if need_indent:
                     self.text.append(indent)
                 self.process_paragraph_item(i)
                 self.text.append("\n")
                 found = True
             elif name == 'pre':
-                if not first_child:
+                if need_indent:
                     self.text.append(indent)
                 self.process_preformatted_item(i)
                 found = True
@@ -656,17 +674,18 @@
                 self.process_dl(i)
                 found = True
             elif name == 'table':
-                if not first_child:
+                if need_indent:
                     self.text.append(indent)
                 self.process_table(i)
                 found = True
-            #else:
-            #    self.process_inline(i)
-            first_child = False
-                
-        if not found:
-            self.process_paragraph_item(node)
-            self.text.append("\n")
+            else:
+                pending.append(i)
+
+            if found:
+                need_indent = True
+
+        if pending:
+            self.empty_paragraph_queue(pending, indent, need_indent)
 
     def process_blockquote(self, node):
         # XXX this does not really work. e.g.: