perl-pod / pod-simple

Framework for Parsing and Formatting POD
http://search.cpan.org/dist/Pod-Simple/
43 stars 59 forks source link

Add select method compatible with Pod::Select #154

Closed haarg closed 2 months ago

haarg commented 1 year ago

This is an incomplete implementation of filtering compatible with Pod::Select. It still needs more tests, documentation, and I'm not certain on the external API yet.

The select method accepts a list of filters using a syntax compatible with Pod::Select. They are compiled to a set of regexes that are meant to match the text content of headings.

The _handle_element_start, _handle_element_end, and _handle_test methods have to be changed to be called indirectly. This allows some of the calls to be skipped (when filtering) and allows collecting the head text to do comparisons.

When encountering a head directive, we stop emitting the events immediately and instead start buffering them. Additionally, any text content is collected as a single string. At the end, we can check that heading text (and its parents) against the filter. If allowed, we emit the queued events before continuing. We save this filtering status so the other maybe know if they should be emitting events.

jkeenan commented 2 months ago

Since this p.r. has been merged into Pod-Simple's master branch, it would be good to get a new CPAN release that we could synch into Perl 5 blead and expose to smoke-testing early in the current Perl 5 dev cycle.