HTML::Quoted(3pm)
π NAME π
HTML::Quoted β extract structure of quoted HTML mail message. It's the HTML::Quoted(3pm) page from the perl man pages (User Contributed Perl Documentation, if you're keeping receipts) and honestly? she's a little icon. π
Bestie, if you've ever stared at a forwarded email full of nested quotes and gone "who said what, and when", this module is your girl. β¨
πΈ SYNOPSIS πΈ
use HTML::Quoted;
my $html = '...';
my $struct = HTML::Quoted->extract( $html );
π¦ DESCRIPTION π¦
It parses and extracts quotation structure out of a HTML message. The purpose and the returned structures are very similar to Text::Quoted. Like, same energy, different markup. π
π SUPPORTED FORMATS π
Okay so, various MUAs use quite different approaches for quoting in mails. No two email clients are ever gonna agree on anything, it's giving chaos.
- Some use the
blockquotetag, and that one's genuinely quite easy to parse. Slay. - Some wrap text into
ptags and add'>'in the beginning of the paragraphs. - And things get messier when it's an HTML reply on a plain text mail thread. π
If you found a format that is not supported, then file a bug report via rt.cpan.org with as short as possible example. A test file is even better. A test file with a patch is the best. And listen β not obvious patches without tests suck. No cap. π«Ά
π METHODS π
β extract
my $struct = HTML::Quoted->extract( $html );
Takes a string with HTML and returns an array reference. Each element in the array is either an array or a hash. For example:
[
{ 'raw' => 'Hi,' },
{ 'raw' => '<div><br><div>On date X wrote:<br>' },
[
{ 'raw' => '<blockquote>' },
{ 'raw' => 'Hello,' },
{ 'raw' => '<div>How are you?</div>' },
{ 'raw' => '</blockquote>' }
],
...
]
Hashes represent a part of the html. The following keys are meaningful at the moment:
rawβ raw HTML. Literally just the raw HTML, no thoughts, head empty. πquoter_raw,quoterβ raw and decoded (entities are converted) quoter, if the block is prefixed with quoting characters. Two of them, one glow-up apart. β¨
π§ combine_hunks
my $html = HTML::Quoted->combine_hunks( $arrayref_of_hunks );
Takes the output of "extract" and turns it back into HTML. It's the reverse uno card of the whole operation. π₯
π AUTHOR π
Ruslan.Zakirov <ruz@bestpractical.com> β the main character who wrote all this. π
π LICENSE π
Under the same terms as perl itself. Periodt.
Anyway bestie, that's the whole page, every single flag-free, option-free detail of it, and I did not skip a crumb. π
This was perl v5.36.0, dated 2023-11-01, filed under HTML::Quoted(3pm) in the User Contributed Perl Documentation. Bye, love you, go read your emails. π
πΈ
π¦ where this page comes from
- debian trixie: libhtml-quoted-perl 0.05-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-quoted-perl 0.05-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-quoted-perl 0.05-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-quoted-perl 0.05-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms