mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 577 forks source link

Add new method to `$dom`, `$dom->each_text`. #2067

Closed tcheukueppo closed 1 year ago

tcheukueppo commented 1 year ago

Hello,

Summary

  1. New $dom method $dom->each_text: which returns text content of every descendant node in a list.
  2. Tests on $dom->each_text.

Motivation

I'd like to have this feature to be table to perform context sensitive parsing on the text content of a given tag(with all it descendant in the most frequent cases) without interference with contents of other tags(which is something that $dom->all_text does not provide), I'm totally aware of $dom->text but that do require me to walk through the $dom data structure and use css selectors which is quite tedious.

kraih commented 1 year ago

Please don't combine multiple independent changes into a single PR. It lowers the chances of it being accepted significantly. Keep it to one commit per PR.

tcheukueppo commented 1 year ago

Sorry, I think it is the perltidy, let me undo that.

kraih commented 1 year ago

I specifically meant that adding each_text and changing the parser regex are unrelated changes.

tcheukueppo commented 1 year ago

After performing some tests I think modifying parser regex isn't worth it and thus no PR for that.

tcheukueppo commented 1 year ago

done

kraih commented 1 year ago

I don't really see the use of this feature i'm afraid. Maybe some more specific examples for use cases would help.

tcheukueppo commented 1 year ago

Really sorry for bothering you guys, I was working on a project and I came across this, I thought that do be useful but turns out that my approach was not the right approach, it is obviously not useful to me now and probably be never useful to anyone out there, I found another technique that did not even required me to monkey_patch anything, thanks for your attention,

tcheukueppo commented 1 year ago

Closing this PR.