Edgewall Software

Ticket #232 (closed defect: fixed)

Opened 7 years ago

Last modified 7 years ago

append transformation doesn't work at the end of stream

Reported by: jhammel@… Owned by: cmlenz
Priority: major Milestone: 0.5
Component: General Version: devel
Keywords: Cc:


trying to insert past the end of stream results in an extra final tag:

>>> foo = '<em>foo</em>'
>>> print HTML(foo) | Transformer('//em').after('bar')

The following patch fixes:

Index: transform.py
--- transform.py	(revision 852)
+++ transform.py	(working copy)
@@ -980,6 +980,7 @@
         :param stream: The marked event stream to filter
+        stopped = False
         for mark, event in stream:
             yield mark, event
             if mark:
@@ -987,13 +988,15 @@
                         mark, event = stream.next()
                     except StopIteration:
+                        stopped = True
                     if not mark:
                     yield mark, event
                 for subevent in self._inject():
                     yield subevent
-                yield mark, event
+                if not stopped:
+                    yield mark, event
 class PrependTransformation(InjectorTransformation):

admittedly this is a niche case but I see no reason not to do this (and am also not sure if other transforms need patching as well)


Change History

Changed 7 years ago by cmlenz

  • status changed from new to closed
  • resolution set to fixed

Alec fixed this in [868].

Add/Change #232 (append transformation doesn't work at the end of stream)


E-mail address and user name can be saved in the Preferences.

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'
Note: See TracTickets for help on using tickets.