Net::A...::Utils(3pm)

πŸ“¦
version 0.19 Β· 2 versions
  • 0.19 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.19 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 needs HTML::TreeBuilder to 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 if String::Tagged::HTML is 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