changeset 105:97dc359ea3e2

invalid output from HTML converter parsing preformatted code, multiline paragraphs: part 2 of 2 fixes moin2 #516
author RogerHaase <haaserd@gmail.com>
date Tue, 14 Apr 2015 06:49:48 -0700
parents 310ef85ca282
children b7f55cf97425
files emeraldtree/tree.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/emeraldtree/tree.py	Sun May 19 22:48:15 2013 +0200
+++ b/emeraldtree/tree.py	Tue Apr 14 06:49:48 2015 -0700
@@ -916,7 +916,12 @@
     def _flush(self):
         if self._data:
             text = "".join(self._data)
-            self._elem[-1].append(text)
+            if self._elem:
+                self._elem[-1].append(text)
+            else:
+                # ignore empty lines in input, typically strings like: "\n", "   \n", "\n\n\n", etc.
+                text = text.strip()
+                assert not text, 'Parsing error: cannot append orphan string to prior node.'
             self._data = []
 
     ##