MsOffi...n::Run(3pm)
π MsOffice::Word::Surgeon::Run β the whole vibe π
okay so bestie, welcome to MsOffice::Word::Surgeon::Run, a little corner of the MsOffice::Word::Surgeon universe. it's an internal representation β like, the backstage dressing room β for a "run of text". yes it lives in the Perl docs, yes it's a 3pm page, no you don't have to be scared. π
β¨ NAME β¨
MsOffice::Word::Surgeon::Run β the internal representation for a "run of text". that's the whole name, that's the whole assignment. π
πΈ DESCRIPTION πΈ
so here's the tea: this thing is used internally by MsOffice::Word::Surgeon for storing a "run of text" inside a MsWord document. it's giving very much backstage crew energy, not main character energy β you're probably not calling it directly, but it's doing the work. π
it loosely corresponds to a <w:r> node in OOXML. loose correspondence, like when you say you'll be ready in five minutes. π¦
but WAIT, there's more β it may also contain an anonymous XML fragment which is the part of the document just before the <w:r> node. why? because it's used for reconstructing the complete document after having changed the contents of some runs. it remembers the little bits so nothing gets lost. iconic behaviour, honestly. β¨
π«Ά METHODS π«Ά
π new
my $run = MsOffice::Word::Surgeon::Run(
xml_before => $xml_string,
props => $properties_string,
inner_texts => [MsOffice::Word::Surgeon::Text(...), ...],
);
Constructor for a new run object. the arguments are, in order of the group chat:
xml_beforeβ a string containing arbitrary XML preceding that run in the complete document. it may be empty but must be present (so don't ghost it, bestie, it has to show up even if it's saying nothing). πpropsβ a string containing XML for the properties of this run (think instructions for bold, italic, font, etc.). important: the module does not parse this information β it just compares the string for equality with the next run. literally just a string comparison, no deep analysis, no therapy. πinner_textsβ an array ofMsOffice::Word::Surgeon::Textobjects, corresponding to the XML<w:t>nodes inside the run. π
π as_xml
my $xml = $run->as_xml;
returns the XML representation of that run. that's it, that's the method. short and slay. π
π merge
$run->merge($next_run);
merge the contents of $next_run together with the current run. this is only possible if both runs have the same properties (same string returned by the props method), and if the next run has an empty xml_before attribute.
if the conditions are not met, an exception is raised. no soft launch, no "let's see how it goes" β it just throws. π¨
β replace
my $xml = $run->replace($pattern, $replacement_callback, %replacement_args);
replaces all occurrences of $pattern within all text nodes by a new string computed by $replacement_callback, and returns a new xml string corresponding to the result of all these replacements. π₯
this is the internal implementation for the public method replace in MsOffice::Word::Surgeon::PackagePart β so it's the understudy that's actually doing the performance, iykyk. π
π§ remove_caps_property
searches in the run properties for a <w:caps/> property; if found, it removes it, and replaces all inner texts by their uppercase equivalents. so it's a glow-up that also makes everything SHOUT. π£β¨
π AUTHOR π
Laurent Dami, <dami AT cpan DOT org<gt>
π COPYRIGHT AND LICENSE π
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. π«Ά
and that's the whole page, bestie. this gem of a doc was served up courtesy of perl v5.40.1, dated 2025-10-05 β so when you cite your sources, say it with your chest. mwah, go forth and merge responsibly. ππβ¨
π¦ where this page comes from
- ubuntu resolute: libmsoffice-word-surgeon-perl 2.11-1 Β· Artistic-2.0
- ubuntu stonking: libmsoffice-word-surgeon-perl 2.11-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms