Net::A...::Utils(3pm)
π Net::A...::Utils(3pm) π
okay so bestie, we're reading the manual for Net::Async::Matrix::Utils β that's a User Contributed Perl Documentation page, and honestly? it's short, it's sweet, and it's doing exactly what it says on the tin. two functions, both absolute icons. let's get into it π«Ά
β¨ NAME β¨
"Net::Async::Matrix::Utils" β support utilities for Net::Async::Matrix. that's it, that's the whole name. short king energy π
πΈ DESCRIPTION πΈ
this section is literally just vibing β there's no prose here, the actual content lives under FUNCTIONS. so like, consider this your little hallway before the main event. no notes, moving on π
π FUNCTIONS π
π¦ parse_formatted_message
$st = parse_formatted_message( $content )
okay so picture this: you've got the content of a m.room.message event, and that event is either m.text or m.emote type. hand it over and you get back a String::Tagged instance β that's the text of the message, but with all the formatting carried along in String::Tagged::Formatting style. no cap β¨
and if the message isn't formatted? or the formatting is some kind of format that isn't recognised? then you just get the plain-text body back, sitting in an instance with no tags. still valid, still cute, just plain π
here's the formats it actually recognises:
org.matrix.custom.htmlβ this one needsHTML::TreeBuilderto be present so it can parse. if that module isn't available, it will be ignored. like, straight up not happening. know that π«
and here's the mapping, since tables aren't a thing in this format, i'm giving you the receipts line by line:
<b>,<strong>β'bold'<i>,<em>β'italic'<u>β'under'<strike>β'strike'<tt>,<code>β'monospace'<font color="..."β'fg'
π build_formatted_message
$content = build_formatted_message( $str )
the glow-up direction this time π« give it either a String::Tagged::Formatting instance or a plain string, and it hands you back a content HASH reference that encodes the formatting of the message.
- plain strings? returned simply as a plain-text body. no drama.
- formatted instances? output as formatted content if possible β that "if possible" is doing a lot of work, bestie, respect it.
here's the one format it outputs:
org.matrix.custom.htmlβ this is what gets output for formatted messages, but only ifString::Tagged::HTMLis available. no module, no HTML, simple as π§
and the mapping, again in list form because we're not doing tables:
'bold'β<strong>'italic'β<em>'under'β<u>'strike'β<strike>'monospace'β<code>'fg'β<font color="...">
not me noticing that the round trip is almost symmetrical but<strong>and<em>come out of the box on the way back, while<b>and<i>also go in. that's just what the docs say, okay? i don't make the rules π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β the legend behind it all π go say hi, or don't, i'm not your mom.
and that's the whole page, bestie!! this was Net::A...::Utils(3pm) from perl v5.36.0, dated 2022-12-10, filed under User Contributed Perl Documentation. mwah, slay, go format some messages π
β¨π
π¦ where this page comes from
- debian bookworm: libnet-async-matrix-perl 0.19-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-async-matrix-perl 0.19-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-async-matrix-perl 0.19-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-async-matrix-perl 0.19-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-async-matrix-perl 0.19-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