CSS::DOM::Util(3pm)

πŸ“¦
version 0.17 Β· 5 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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