CSS::DOM::Util(3pm)
π CSS::DOM::Util β the manual page, but make it slay π
okay bestie, so this is the manual page for CSS::DOM::Util(3pm), a lil Perl module from the User Contributed Perl Documentation section, and it's literally all about helping you deal with CSS tokens. token girlbossery. let's get into it β¨
β¨ NAME β¨
CSS::DOM::Util β utility functions for dealing with CSS tokens π
πΈ VERSION πΈ
Version 0.17 β yes queen, we're on 0.17, keep up π
π¦ SYNOPSIS π¦
so here's how you pull the whole squad in. either grab everything with :all:
use CSS::DOM::Util ':all';
or, if you're a pick-me and only want specific functions, name them by hand:
# or:
use CSS::DOM::Util qw[
escape unescape
escape_ident unescape_url
escape_str unescape_str
];
both are valid, both are iconic, pick your vibe π«Ά
π DESCRIPTION π
This module provides utility functions for dealing with CSS tokens. that's it, that's the whole gig. it's a lil toolbox of escape/unescape besties and they all ate π₯
π FUNCTIONS π
okay so here's the thing you NEED to know before anything else: all functions below that take one argument have a ($) prototype, so they have the same precedence as closedir and delete. so like. respect the prototype. it's giving operator precedence realness π
π escape $string, $chars_to_escape
This escapes any characters in $string that occur in $chars_to_escape, which is interpreted as a regular expression. β οΈ the regexp must consume just one character β otherwise you'll find chars missing from the output. not "maybe missing". missing. gone. ghosted π so don't do that.
ASCII vertical whitespace (except the vertical tab) is always escaped. always. no negotiating.
So how does it escape stuff? Printable non-alphanumeric ASCII characters and the space character get escaped with a single backslash. other characters are encoded in hexadecimal. cute, right? β¨
and here's the sneaky smart part: escape also considers that you might want to include the escaped string in a larger string, so it appends a space if the escaped string ends with a hexadecimal escape with fewer than six digits. it's looking out for you. it's a considerate king π
πΈ unescape $string
This turns something like "H\65llo" into "Hello" (including quotes). so it's the reverse bestie. the un-girlboss. it takes the escape-y mess and hands you back the readable version, quotes and all π
π escape_ident $string
π escape_ident $string, $more_chars_to_escape
This escapes $string as a CSS identifier, escaping also any characters matched by $more_chars_to_escape. so it's already doing ident-safe escaping, and then you can pile on extra characters you personally want gone. extra credit energy, we love to see it β
π§ unescape_url $url_token
Returns the URL that the token represents. simple. clean. does exactly what it says on the tin, no notes π
π escape_str $string
Returns a CSS string token containing $string (within quotes; characters possibly escaped). so you hand it a string, it hands you back a proper CSS string token, quotes included, escapes where needed. periodt π
π¦ unescape_str $string_token
Returns the value that a CSS string token represents. the reverse of the one above, obviously. token in, value out. iykyk π
π« SEE ALSO π«
CSS::DOM β go look at that one too bestie, it's the main character of this whole situation π«Ά
and that's the whole page!! written for perl v5.36.0, dated 2023-08-02, and it's CSS::DOM::Util(3pm) forever and always. mwah π stay escaped, stay unescaped, stay hydrated π§β¨
π¦ where this page comes from
- debian trixie: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcss-dom-perl 0.17-3 Β· 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