Opened 17 years ago
Closed 17 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: |
Description
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') <em>foo</em>bar</em>
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 @@ try: mark, event = stream.next() except StopIteration: + stopped = True break if not mark: break 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 (1)
comment:1 Changed 17 years ago by cmlenz
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
Alec fixed this in [868].