servo / html5ever

High-performance browser-grade HTML5 parser
Other
2.1k stars 214 forks source link

Are there callbacks when processing closed labels? #543

Open ddx533534 opened 2 months ago

ddx533534 commented 2 months ago

when label closed, I wanna do something, Is there anyway to implement it? For example:

// when encounter </div> I want to add a line break for the text
<div><span>A</span></div>
max-heller commented 2 months ago

I hoped TreeSink::pop() would allow this, but it doesn't seem to be called when I expect it to.

max-heller commented 2 months ago

Seems like #149 is asking for the same thing. https://github.com/servo/html5ever/issues/149#issuecomment-298840873 suggests pop() may be usable, but that it isn't always called

ddx533534 commented 1 month ago
    /// Indicate that a node was popped off the stack of open elements.
    fn pop(&mut self, _node: &Self::Handle) {}

Yep, I have tried TreeSink::pop(), but it isn't called every time that encountered end tags. Maybe it wasn't designed to do that.