01 May 2022 06:26:44 UTC
- Distribution: MsOffice-Word-Surgeon
- Module version: 2.0
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (248 / 0 / 44)
- KwaliteeBus factor: 1
- 76.30% Coverage
- License: artistic_2
- Perl: v5.24.0
- Activity24 month
- Download (58.83KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionDAMI Laurent Dami
MsOffice::Word::Surgeon::Run - internal representation for a "run of text"
This is used internally by MsOffice::Word::Surgeon for storing a "run of text" in a MsWord document. It loosely corresponds to a
<w:r>node in OOXML, but may also contain an anonymous XML fragment which is the part of the document just before the
<w:r>node -- used for reconstructing the complete document after having changed the contents of some runs.
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. Arguments are :
A string containing arbitrary XML preceding that run in the complete document. The string may be empty but must be present.
A string containing XML for the properties of this run (for example instructions for bold, italic, font, etc.). The module does not parse this information; it just compares the string for equality with the next run.
An array of MsOffice::Word::Surgeon::Text objects, corresponding to the XML
<w:t>nodes inside the run.
my $xml = $run->as_xml;
Returns the XML representation of that run.
Merge the contents of
$next_runtogether with the current run. This is only possible if both runs have the same properties (same string returned by the
propsmethod), and if the next run has an empty
xml_beforeattribute; if the conditions are not met, an exception is raised.
my $xml = $run->replace($pattern, $replacement_callback, %replacement_args);
Replaces all occurrences of
$patternwithin 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 public method "replace" in MsOffice::Word::Surgeon.
Searches in the run properties for a
<w:caps/>property; if found, removes it, and replaces all inner texts by their uppercase equivalents.
Laurent Dami, <dami AT cpan DOT org<gt>
Copyright 2019-2022 by Laurent Dami.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install MsOffice::Word::Surgeon, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install MsOffice::Word::Surgeon
For more information on module installation, please visit the detailed CPAN module installation guide.