Is there any reason why HTMLRewriter doesn’t have a callback for an element end tag? I don’t think it’s a limitation of the streaming parser since it’s capable of replacing a tag and the corresponding end tag.
Having an end tag would allow context, specifically, you could know the parent of a given tag. Right now when the rewrite sees a ‘b’ tag, it can’t differentiate between:
It would be extremely useful to be able to transform ‘b’ based on its DOM context.