changeset 1737:fa04be6b7ea4

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 13 Jan 2007 21:55:21 +0100
parents 6e4acd9904d7 (diff) 5e870f4e5d2e (current diff)
children 7ac15b5e2db8
files
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jan 13 21:09:45 2007 +0100
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jan 13 21:55:21 2007 +0100
@@ -465,6 +465,7 @@
 class convert_tree(visitor):
     white_space = object()
     new_line = object()
+    new_line_dont_remove = object()
 
     def __init__(self, request, pagename):
         self.request = request
@@ -510,6 +511,9 @@
                 else:
                     text[i] = "\n"
                     i += 1
+            elif text[i] is self.new_line_dont_remove:
+                text[i] = "\n"
+                i += 1
             else:
                 i += 1
 
@@ -582,7 +586,7 @@
         if name == 'ol':
             class_ = listitem.getAttribute("class")
             if class_ == "gap":
-                before = "\n"
+                before = self.new_line_dont_remove
             if list.hasAttribute("type"):
                 type = list.getAttribute("type")
             else:
@@ -591,7 +595,7 @@
         elif name == 'ul':
             class_ = listitem.getAttribute("class")
             if class_ == "gap":
-                before = "\n"
+                before = self.new_line_dont_remove
             style = listitem.getAttribute("style")
             if re.match(ur"list-style-type:\s*none", style, re.I):
                 markup = ". "
@@ -611,7 +615,7 @@
                 name = i.localName
                 if name == 'dt':
                     before, indent, markup = self._get_list_item_markup(node, i)
-                    self.text.append(before+indent)
+                    self.text.extend([before, indent])
                     text = self.node_list_text_only(i.childNodes)
                     self.text.append(text.replace("\n", " "))
                 elif name == 'dd':
@@ -621,7 +625,7 @@
                     raise ConvertError("Illegal list element %s" % i.localName)
         self.depth -= 1
         if self.depth == 0:
-            self.text.append(self.new_line)
+            self.text.append(self.new_line_dont_remove)
 
     def process_list(self, node):
         self.depth += 1
@@ -630,7 +634,7 @@
                 name = i.localName
                 if name == 'li':
                     before, indent, markup = self._get_list_item_markup(node, i)
-                    self.text.append(before+indent+markup)
+                    self.text.extend([before, indent, markup])
                     self.process_list_item(i, indent)
                 elif name in ('ol', 'ul',):
                     self.process_list(i)
@@ -640,7 +644,7 @@
                     raise ConvertError("Illegal list element %s" % i.localName)
         self.depth -= 1
         if self.depth == 0:
-            self.text.append(self.new_line)
+            self.text.append(self.new_line_dont_remove)
 
     process_ul = process_list
     process_ol = process_list
@@ -857,7 +861,7 @@
                     self.text.append(i.data)
                     #print "'%s'" % i.data
                 elif i.localName == 'br':
-                    self.text.append(self.new_line)
+                    self.text.append(self.new_line_dont_remove)
                 else:
                     pass
                     #print i.localName
@@ -995,7 +999,7 @@
                     raise ConvertError("process_table: Don't support %s element" % name)
             #else:
             #    raise ConvertError("Unexpected node: %r" % i)
-        self.text.append(self.new_line)
+        self.text.append(self.new_line_dont_remove)
 
     def process_caption(self, table, node, style=""):
         # get first row
@@ -1023,7 +1027,7 @@
             colspan = 1
         text = self.node_list_text_only(node.childNodes).replace('\n', ' ').strip()
         if text:
-            self.text.extend(["%s'''%s%s'''||" % ('||' * colspan, style, text), self.new_line])
+            self.text.extend(["%s'''%s%s'''||" % ('||' * colspan, style, text), self.new_line_dont_remove])
 
     def process_table_data(self, node, style=""):
         if node.hasAttribute("colspan"):
@@ -1070,7 +1074,7 @@
                     style = ""
                 else:
                     raise ConvertError("process_table_record: Don't support %s element" % name)
-        self.text.extend(["||", self.new_line])
+        self.text.extend(["||", self.new_line_dont_remove])
 
     def process_a(self, node):
         scriptname = self.request.getScriptname()