line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MsOffice::Word::Surgeon::Utils; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Exporter qw/import/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
213
|
|
6
|
|
|
|
|
|
|
our @EXPORT = qw/maybe_preserve_spaces is_at_run_level/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.02'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub maybe_preserve_spaces { |
11
|
1551
|
|
|
1551
|
1
|
2848
|
my ($txt) = @_; |
12
|
1551
|
100
|
100
|
|
|
7840
|
return $txt =~ /^\s/ || $txt =~ /\s$/ ? ' xml:space="preserve"' : ''; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub is_at_run_level { |
16
|
2092
|
|
|
2092
|
1
|
4063
|
my ($xml) = @_; |
17
|
2092
|
|
|
|
|
9544
|
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
|
|
|
|
|
|
|
|