line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MsOffice::Word::Surgeon::Utils; |
2
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Exporter qw/import/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
274
|
|
6
|
|
|
|
|
|
|
our @EXPORT = qw/maybe_preserve_spaces is_at_run_level/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub maybe_preserve_spaces { |
11
|
2587
|
|
|
2587
|
1
|
4741
|
my ($txt) = @_; |
12
|
2587
|
100
|
100
|
|
|
12325
|
return $txt =~ /^\s/ || $txt =~ /\s$/ ? ' xml:space="preserve"' : ''; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub is_at_run_level { |
16
|
2082
|
|
|
2082
|
1
|
4153
|
my ($xml) = @_; |
17
|
2082
|
|
|
|
|
9630
|
return $xml =~ m[</w:(?:r|del|ins)>$]; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=encoding ISO-8859-1 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
MsOffice::Word::Surgeon::Utils - utility functions for MsOffice::Word::Surgeon |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use MsOffice::Word::Surgeon::Utils qw(maybe_preserve_spaces); |
34
|
|
|
|
|
|
|
my $attr = maybe_preserve_spaces($some_text); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Functions in this module are used internally by L<MsOffice::Word::Surgeon>. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 FUNCTIONS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 maybe_preserve_spaces |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $attr = maybe_preserve_spaces($some_text); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Returns the XML attribute to be inserted into C<< <w:t> >> nodes and |
48
|
|
|
|
|
|
|
C<< <w:delText> >> nodes when the literal text within the node starts |
49
|
|
|
|
|
|
|
or ends with a space -- in that case the XML should contain the |
50
|
|
|
|
|
|
|
attribute C<< xml:space="preserve" >> |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 is_at_run_level |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
if (is_at_run_level($xml)) {...} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns true if the given XML fragment ends with a C<< </w:r> >>, |
57
|
|
|
|
|
|
|
C<< </w:del> >> or C<< </w:ins> >> node. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|