Edgewall Software

Opened 10 years ago

Closed 10 years ago

#232 closed defect (fixed)

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)

Attachments (0)

Change History (1)

comment:1 Changed 10 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Alec fixed this in [868].

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.