HTML5::StreamingParser
Inherits HTML5::Parser < Reference < Object
StreamingParser wraps the standard HTML5 parser and emits SAX-style events
via a StreamingHandler as the document tree is constructed.
It works by subclassing Parser and intercepting the tree-building methods
(add_child, add_text) to emit events while preserving correct HTML5
parsing behavior. Element close events are emitted via a custom NodeStack
that intercepts pop operations.
Constructors
Instance methods
add_text(text : String)
Override add_text to emit text events correctly for all three code paths:
- Foster parenting (bypasses add_child)
- Appending to existing text node (bypasses add_child)
- New text node (goes through add_child)
Override oe= to emit close events for elements removed by stack slicing.
Many insertion modes do p.oe = p.oe[...i] to pop multiple elements.