Mojo::D...Entities(3)
π NAME π
Mojo::DOM58::Entities β bestie, this is the module that escapes or unescapes HTML entities in strings β¨ (and yes, that's literally the whole job, and it does it so well)
πΈ SYNOPSIS πΈ
okay so first you gotta pull in the two functions you want, like:
use Mojo::DOM58::Entities qw(html_escape html_unescape);
my $str = 'foo & bar';
$str = html_unescape $str; # "foo & bar"
$str = html_escape $str; # "foo & bar"
see how it just flips back and forth?? iconic behaviour fr π
π¦ DESCRIPTION π¦
Mojo::DOM58::Entities is giving "small module, huge slay". It's packing functions for escaping and unescaping HTML entities for Mojo::DOM58, and it's based on functions from Mojo::Util (iykyk).
And here's the lil detail that matters: all functions are exported on demand β so you have to ask for them in your use line. No free handouts, no cap π«Ά
π FUNCTIONS π
π html_attr_unescape
my $str = html_attr_unescape $escaped;
This one is basically html_unescape's cousin with β¨special rulesβ¨ β it handles the special rules from the HTML Living Standard <https://html.spec.whatwg.org> for HTML attributes.
Watch this, it's genuinely so cool:
# "foo=bar<est=baz"
html_attr_unescape 'foo=bar<est=baz';
# "foo=bar<est=baz"
html_attr_unescape 'foo=bar<est=baz';
no semicolon? no problem. it knows. main character energy honestly π
π html_escape
my $escaped = html_escape $str;
This one's job is escaping the unsafe characters &, <, >, ", and ' in a string. five little gremlins, all handled π
html_escape '<div>'; # "<div>"
π html_unescape
my $str = html_unescape $escaped;
Unescape all HTML entities in a string, according to the HTML Living Standard <https://html.spec.whatwg.org/#named-character-references-table>. all of them. every single one. obsessed.
html_unescape '<div>'; # "<div>"
π BUGS π
okay bestie, listen up, this part is important π
If you've got issues related to the format of this distribution or Perl 5.8 support, those go to the public bugtracker.
Any other issues should be reported directly to the upstream Mojolicious issue tracker.
so like. please file it in the right place, the maintainers will love you for it π«Ά
β¨ AUTHOR β¨
Dan Book <dbook@cpan.org> β the one who did this π
Also, for the record: the code and tests are adapted from Mojo::Util, which is a set of utilities by the Mojolicious team. Respect where it's due π
π COPYRIGHT AND LICENSE π
Copyright (c) 2008-2016 Sebastian Riedel and others.
Copyright (c) 2016 Dan Book for adaptation to standalone format.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
free software!! slay!! π
π SEE ALSO π
HTML::Entitiesβ the other one, the classic, the OG. go peek if you're curious π
and that's the whole page bestie!! π this was Mojo::DOM58::Entities(3) from the User Contributed Perl Documentation, and just so you have the receipts: it's perl v5.42.0, dated 2025-07-25. mwah, go escape some entities, you got this π
β¨π¦
π¦ where this page comes from
- fedora 43: perl-Mojo-DOM58 3.002-2.fc43 Β· Artistic-2.0 AND CC0-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms