MsOffi...:Utils(3pm)

πŸ“¦
version 2.11 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– MsOffi...:Utils(3pm) πŸ’–

okay so bestie, welcome to MsOffice::Word::Surgeon::Utils β€” it's part of the User Contributed Perl Documentation crew, and it's basically the little backstage helper squad for MsOffice::Word::Surgeon. no cap. ✨


🌸 NAME 🌸

MsOffice::Word::Surgeon::Utils β€” the utility functions that do the behind-the-scenes lifting for MsOffice::Word::Surgeon. it's giving backstage crew with main character energy fr fr πŸŽ€


✨ SYNOPSIS ✨

use MsOffice::Word::Surgeon::Utils qw(maybe_preserve_spaces);
my $attr = maybe_preserve_spaces($some_text);

like, that's it. that's the whole vibe check. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions? they're used internally by MsOffice::Word::Surgeon. meaning: they're the helpers doing the work behind the curtain, not the ones you're meant to be chatting up at the party. iykyk. πŸ™ˆ


πŸ‘‘ FUNCTIONS πŸ‘‘

πŸŽ€ maybe_preserve_spaces

my $attr = maybe_preserve_spaces($some_text);

returns the XML attribute you need to drop into <w:t> nodes and <w:delText> nodes whenever the literal text inside the node starts or ends with a space β€” because in that case the XML needs to contain the attribute xml:space="preserve". literally just doing its job so your spaces don't get ghosted. ✨

🧚 is_at_run_level

if (is_at_run_level($xml)) {...}

returns true if the XML fragment you handed it ends with a </w:r>, </w:del> or </w:ins> node. it's basically the "are we at run level, bestie?" check. πŸ’œ

πŸ“ parse_attrs

my %attrs = parse_attrs($lst_attrs)

returns a hash of name-value pairs parsed out of the input string. the values may be wrapped in single quotes or double quotes (both are valid, we don't play favourites πŸ’…), and the values get entity-decoded for you. slay.

🌈 decode_entities

decode_entities($string)

decodes XML entities inside the string you pass in β€” and heads up, it's doing that in-place. so it's not returning you a shiny new string, it's editing the one you gave it. glow-up in place, iconic behaviour tbh. πŸ”₯

⭐ encode_entities

encode_entities($string)

the mirror-image queen: encodes XML entities inside the string β€” also in-place. same deal, it transforms the string you handed over rather than making a copy. πŸ‘‘


Copyright 2019-2024 by Laurent Dami.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. fr fr, go forth and remix. 🫢


and that's a wrap, bestie!! this page was served up by perl v5.40.1 on 2025-10-05, and the whole doc lives under the MsOffi...:Utils(3pm) header. mwah. πŸ’‹πŸ’–

πŸ“¦ where this page comes from