| 1 | package Pod::Simple::RTF; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | #sub DEBUG () {4}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | #sub Pod::Simple::DEBUG () {4}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | #sub Pod::Simple::PullParser::DEBUG () {4}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | our $VERSION = '3.48'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Pod::Simple::PullParser (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | our @ISA; | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | BEGIN {@ISA = ('Pod::Simple::PullParser')} | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | BEGIN { *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 270 | ▶ | sub to_uni ($) { # Convert native code point to Unicode | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_uni: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 270 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Broken for early EBCDICs | ||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 270 | ▶ | $x = chr utf8::native_to_unicode(ord $x) if "$]" >= 5.007_003 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
"$]" >= "5.007003" and
MC/DC0%0/1
"$]" >= "5.007003" and
"$]" >= "5.007003"
Truth table50%1/2
A
A= "$]" >= "5.007003"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | && ord("A") != 65; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 270 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # We escape out 'F' so that we can send RTF files thru the mail without the | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # slightest worry that paragraphs beginning with "From" will get munged. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # We also escape '\', '{', '}', and '_' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | my $map_to_self = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEGHIJKLMNOPQRSTUVWXYZ[]^`abcdefghijklmnopqrstuvwxyz|~'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | our $WRAP; | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | $WRAP = 1 unless defined $WRAP; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | our %Escape = ( | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Start with every character mapping to its hex equivalent | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | map( (chr($_) => sprintf("\\'%02x", $_)), 0 .. 0xFF), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Override most ASCII printables with themselves (or on non-ASCII platforms, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # their ASCII values. This is because the output is UTF-16, which is always | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # based on Unicode code points) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | map( ( substr($map_to_self, $_, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | => to_uni(substr($map_to_self, $_, 1))), 0 .. length($map_to_self) - 1), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # And some refinements: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | "\r" => "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | "\cj" => "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | "\n" => "\n\\line ", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | "\t" => "\\tab ", # Tabs (altho theoretically raw \t's are okay) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | "\f" => "\n\\page\n", # Formfeed | ||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | "-" => "\\_", # Turn plaintext '-' into a non-breaking hyphen | ||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | $Pod::Simple::nbsp => "\\~", # Latin-1 non-breaking space | ||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $Pod::Simple::shy => "\\-", # Latin-1 soft (optional) hyphen | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # CRAZY HACKS: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | "\n" => "\\line\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | "\r" => "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | "\cb" => "{\n\\cs21\\lang1024\\noproof ", # \\cf1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | "\cc" => "}", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # Generate a string of all the characters in %Escape that don't map to | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # themselves. First, one without the hyphen, then one with. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | my $escaped_sans_hyphen = ""; | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | $escaped_sans_hyphen .= $_ for grep { $_ ne $Escape{$_} && $_ ne '-' } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_ ne $Pod::Simple::RTF::Escape{$_} && $_ ne '-'
MC/DC100%2/2
$_ ne $Pod::Simple::RTF::Escape{$_} && $_ ne '-'
$_ ne $Pod::Simple::RTF::Escape{$_}
$_ ne '-'
Truth table100%3/3
A && B
A= $_ ne $Pod::Simple::RTF::Escape{$_}B= $_ ne '-'
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | sort keys %Escape; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | my $escaped = "-$escaped_sans_hyphen"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # Then convert to patterns | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | $escaped_sans_hyphen = qr/[\Q$escaped_sans_hyphen \E]/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | $escaped= qr/[\Q$escaped\E]/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | ▶ | sub _openclose { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_openclose: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | return map {; | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 75 | ▶ | m/^([-A-Za-z]+)=(\w[^\=]*)$/s or die "what's <$_>?"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 75 | ( $1, "{\\$2\n", "/$1", "}" ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | my @_to_accept; | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | our %Tagmap = ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # 'foo=bar' means ('foo' => '{\bar'."\n", '/foo' => '}') | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | _openclose( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 'B=cs18\b', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'I=cs16\i', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 'U=cs30\ul', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 'C=cs19\f1\lang1024\noproof', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 'F=cs17\i\lang1024\noproof', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 'VerbatimI=cs26\i', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'VerbatimB=cs27\b', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 'VerbatimBI=cs28\b\i', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | map {; m/^([-a-z]+)/s && push @_to_accept, $1; $_ } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | qw[ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | underline=ul smallcaps=scaps shadow=shad | ||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | superscript=super subscript=sub strikethrough=strike | ||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | outline=outl emboss=embo engrave=impr | ||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | dotted-underline=uld dash-underline=uldash | ||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | dot-dash-underline=uldashd dot-dot-dash-underline=uldashdd | ||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | double-underline=uldb thick-underline=ulth | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | word-underline=ulw wave-underline=ulwave | ||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # But no double-strikethrough, because MSWord can't agree with the | ||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # RTF spec on whether it's supposed to be \strikedl or \striked1 (!!!) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # Bit of a hack here: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 'L=pod' => '{\cs22\i'."\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 'L=url' => '{\cs23\i'."\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 'L=man' => '{\cs24\i'."\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | '/L' => '}', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 'Data' => "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | '/Data' => "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 'Verbatim' => "\n{\\pard\\li#rtfindent##rtfkeep#\\plain\\s20\\sa180\\f1\\fs18\\lang1024\\noproof\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | '/Verbatim' => "\n\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 'VerbatimFormatted' => "\n{\\pard\\li#rtfindent##rtfkeep#\\plain\\s20\\sa180\\f1\\fs18\\lang1024\\noproof\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | '/VerbatimFormatted' => "\n\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 'Para' => "\n{\\pard\\li#rtfindent#\\sa180\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | '/Para' => "\n\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 'head1' => "\n{\\pard\\li#rtfindent#\\s31\\keepn\\sb90\\sa180\\f2\\fs#head1_halfpoint_size#\\ul{\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | '/head1' => "\n}\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'head2' => "\n{\\pard\\li#rtfindent#\\s32\\keepn\\sb90\\sa180\\f2\\fs#head2_halfpoint_size#\\ul{\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | '/head2' => "\n}\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 'head3' => "\n{\\pard\\li#rtfindent#\\s33\\keepn\\sb90\\sa180\\f2\\fs#head3_halfpoint_size#\\ul{\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | '/head3' => "\n}\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 'head4' => "\n{\\pard\\li#rtfindent#\\s34\\keepn\\sb90\\sa180\\f2\\fs#head4_halfpoint_size#\\ul{\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | '/head4' => "\n}\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # wordpad borks on \tc\tcl1, or I'd put that in =head1 and =head2 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 'item-bullet' => "\n{\\pard\\li#rtfindent##rtfitemkeepn#\\sb60\\sa150\\fi-120\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | '/item-bullet' => "\n\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 'item-number' => "\n{\\pard\\li#rtfindent##rtfitemkeepn#\\sb60\\sa150\\fi-120\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | '/item-number' => "\n\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 'item-text' => "\n{\\pard\\li#rtfindent##rtfitemkeepn#\\sb60\\sa150\\fi-120\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | '/item-text' => "\n\\par}\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # we don't need any styles for over-* and /over-* | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | my $new = shift->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 3 | $new->nix_X_codes(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | $new->nbsp_for_S(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | $new->accept_targets( 'rtf', 'RTF' ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | $new->{'Tagmap'} = {%Tagmap}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | $new->accept_codes(@_to_accept); | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | $new->accept_codes('VerbatimFormatted'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | DEBUG > 2 and print STDERR "To accept: ", join(' ',@_to_accept), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $new->doc_lang( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ( $ENV{'RTFDEFLANG'} || '') =~ m/^(\d{1,10})$/s ? $1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | : ($ENV{'RTFDEFLANG'} || '') =~ m/^0?x([a-fA-F0-9]{1,10})$/s ? hex($1) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # yes, tolerate hex! | ||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | : ($ENV{'RTFDEFLANG'} || '') =~ m/^([a-fA-F0-9]{4})$/s ? hex($1) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%3/6
$ENV{'RTFDEFLANG'} || ''
$ENV{'RTFDEFLANG'} || ''
$ENV{'RTFDEFLANG'} || ''
MC/DC0%0/1
$ENV{'RTFDEFLANG'} || ''
$ENV{'RTFDEFLANG'}
MC/DC0%0/1
$ENV{'RTFDEFLANG'} || ''
$ENV{'RTFDEFLANG'}
MC/DC0%0/1
$ENV{'RTFDEFLANG'} || ''
$ENV{'RTFDEFLANG'}
Truth table50%1/2
A
A= $ENV{'RTFDEFLANG'}
Truth table50%1/2
A
A= $ENV{'RTFDEFLANG'}
Truth table50%1/2
A
A= $ENV{'RTFDEFLANG'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # yes, tolerate even more hex! | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | : '1033' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | $new->head1_halfpoint_size(32); | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | $new->head2_halfpoint_size(28); | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | $new->head3_halfpoint_size(25); | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | $new->head4_halfpoint_size(22); | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | $new->codeblock_halfpoint_size(18); | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | $new->header_halfpoint_size(17); | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | $new->normal_halfpoint_size(25); | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | __PACKAGE__->_accessorize( | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 'doc_lang', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 'head1_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 'head2_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 'head3_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 'head4_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 'codeblock_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 'header_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 'normal_halfpoint_size', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 'no_proofing_exemptions', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=4 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | ▶ | return $self->do_middle if $self->bare_output; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | return | ||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 3 | ▶ | $self->do_beginning && $self->do_middle && $self->do_end; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$self->do_beginning && $self->do_middle && $self->do_end
$self->do_beginning and $self->do_middle
MC/DC0%0/3
$self->do_beginning && $self->do_middle && $self->do_end
$self->do_beginning
$self->do_middle
$self->do_end
Truth table25%1/4
A and B && C
A= $self->do_beginningB= $self->do_middleC= $self->do_end
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # Match something like an identifier. Prefer XID if available, then plain ID, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # then just ASCII | ||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | my $id_re = Pod::Simple::BlackBox::my_qr('[\'_\p{XIDS}][\'\p{XIDC}]+', "ab"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | ▶ | $id_re = Pod::Simple::BlackBox::my_qr('[\'_\p{IDS}][\'\p{IDC}]+', "ab") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | unless $id_re; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | ▶ | $id_re = qr/['_a-zA-Z]['a-zA-Z0-9_]+/ unless $id_re; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | ▶ | sub do_middle { # the main work | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_middle: called CC=39 SCAR=54.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 3 | my $fh = $self->{'output_fh'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | my($token, $type, $tagname, $scratch); | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | my @stack; | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | my @indent_stack; | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | ▶ | $self->{'rtfindent'} = 0 unless defined $self->{'rtfindent'}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | ▶ | while($token = $self->get_token) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 63 | ▶ | if( ($type = $token->type) eq 'text' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 19 | ▶ | if( $self->{'rtfverbatim'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | DEBUG > 1 and print STDERR " $type " , $token->text, " in verbatim!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | rtf_esc(0, $scratch = $token->text); # 0 => Don't escape hyphen | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | print $fh $scratch; | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 18 | DEBUG > 1 and print STDERR " $type " , $token->text, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 18 | $scratch = $token->text; | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 18 | $scratch =~ tr/\t\cb\cc/ /d; | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 18 | ▶ | $self->{'no_proofing_exemptions'} or $scratch =~ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | s/(?: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | | | ||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | (?<=[\r\n\t "\[\<\(]) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ) # start on whitespace, sequence-start, or quote | ||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ( # something looking like a Perl token: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | [\$\@\:\<\*\\_]\S+ # either starting with a sigil, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | | | ||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # or starting alpha, but containing anything strange: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ${id_re}[\$\@\:_<>\(\\\*]\S+ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | /\cb$1\cc/xsg | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 18 | rtf_esc(1, $scratch); # 1 => escape hyphen | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 18 | ▶ | $scratch =~ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | s/( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | [^\r\n]{65} # Snare 65 characters from a line | ||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | [^\r\n ]{0,50} # and finish any current word | ||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | (\ {1,10})(?![\r\n]) # capture some spaces not at line-end | ||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | /$1$2\n/gx # and put a NL before those spaces | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | if $WRAP; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # This may wrap at well past the 65th column, but not past the 120th. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 18 | print $fh $scratch; | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } elsif( $type eq 'start' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | DEBUG > 1 and print STDERR " +$type ",$token->tagname, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 22 | " (", map("<$_> ", %{$token->attr_hash}), ")\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 22 | ▶ | if( ($tagname = $token->tagname) eq 'Verbatim' | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition66%2/3
($tagname = $token->tagname) eq "Verbatim" or $tagname eq "VerbatimFormatted"
MC/DC50%1/2
($tagname = $token->tagname) eq "Verbatim" or $tagname eq "VerbatimFormatted"
($tagname = $token->tagname) eq "Verbatim"
$tagname eq "VerbatimFormatted"
Truth table66%2/3
A or B
A= ($tagname = $token->tagname) eq "Verbatim"B= $tagname eq "VerbatimFormatted"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | or $tagname eq 'VerbatimFormatted' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | ++$self->{'rtfverbatim'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my $next = $self->get_token; | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | next unless defined $next; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | my $line_count = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | ▶ | if($next->type eq 'text') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | my $t = $next->text_r; | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | while( $$t =~ m/$/mg ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 15 | ▶ | last if ++$line_count > 15; # no point in counting further | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | DEBUG > 3 and print STDERR " verbatim line count: $line_count\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | $self->unget_token($next); | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | $self->{'rtfkeep'} = ($line_count > 15) ? '' : '\keepn' ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } elsif( $tagname =~ m/^item-/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my @to_unget; | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $text_count_here = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $self->{'rtfitemkeepn'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # Some heuristics to stop item-*'s functioning as subheadings | ||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # from getting split from the things they're subheadings for. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # It's not terribly pretty, but it really does make things pretty. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | push @to_unget, $self->get_token; | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | pop(@to_unget), last unless defined $to_unget[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # Erroneously used to be "unshift" instead of pop! Adds instead | ||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # of removes, and operates on the beginning instead of the end! | ||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if($to_unget[-1]->type eq 'text') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if( ($text_count_here += length ${$to_unget[-1]->text_r}) > 150 ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | DEBUG > 1 and print STDERR " item-* is too long to be keepn'd.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ▶ | } elsif (@to_unget > 1 and | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
@to_unget > 1 and $to_unget[-2]->type eq "end" and $to_unget[-2]->tagname =~ /^item-/s
@to_unget > 1 and $to_unget[-2]->type eq "end"
MC/DC0%0/3
@to_unget > 1 and $to_unget[-2]->type eq "end" and $to_unget[-2]->tagname =~ /^item-/s
@to_unget > 1
$to_unget[-2]->type eq "end"
$to_unget[-2]->tagname =~ /^item-/s
Truth table0%0/4
A and B and C
A= @to_unget > 1B= $to_unget[-2]->type eq "end"C= $to_unget[-2]->tagname =~ /^item-/s
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | $to_unget[-2]->type eq 'end' and | ||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | $to_unget[-2]->tagname =~ m/^item-/s | ||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # Bail out here, after setting rtfitemkeepn yea or nay. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $self->{'rtfitemkeepn'} = '\keepn' if | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$to_unget[-1]->type eq "start" and $to_unget[-1]->tagname eq "Para"
MC/DC0%0/2
$to_unget[-1]->type eq "start" and $to_unget[-1]->tagname eq "Para"
$to_unget[-1]->type eq "start"
$to_unget[-1]->tagname eq "Para"
Truth table0%0/3
A and B
A= $to_unget[-1]->type eq "start"B= $to_unget[-1]->tagname eq "Para"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | $to_unget[-1]->type eq 'start' and | ||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | $to_unget[-1]->tagname eq 'Para'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | DEBUG > 1 and printf STDERR " item-* before %s(%s) %s keepn'd.\n", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | $to_unget[-1]->type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | $to_unget[-1]->can('tagname') ? $to_unget[-1]->tagname : '', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $self->{'rtfitemkeepn'} ? "gets" : "doesn't get"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } elsif (@to_unget > 40) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | DEBUG > 1 and print STDERR " item-* now has too many tokens (", | |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | scalar(@to_unget), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | (DEBUG > 4) ? (q<: >, map($_->dump, @to_unget)) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | ") to be keepn'd.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | last; # give up | |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # else keep while'ing along | ||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # Now put it aaaaall back... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->unget_token(@to_unget); | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } elsif( $tagname =~ m/^over-/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | push @stack, $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | push @indent_stack, | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | int($token->attr('indent') * 4 * $self->normal_halfpoint_size); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | DEBUG and print STDERR "Indenting over $indent_stack[-1] twips.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->{'rtfindent'} += $indent_stack[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } elsif ($tagname eq 'L') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | $tagname .= '=' . ($token->attr('type') || 'pod'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$token->attr('type') || 'pod'
MC/DC0%0/1
$token->attr('type') || 'pod'
$token->attr('type')
Truth table0%0/2
A
A= $token->attr('type')
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } elsif ($tagname eq 'Data') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $next = $self->get_token; | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | next unless defined $next; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | unless( $next->type eq 'text' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->unget_token($next); | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | DEBUG and print STDERR " raw text ", $next->text, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | printf $fh "\n" . $next->text . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 22 | ▶ | defined($scratch = $self->{'Tagmap'}{$tagname}) or next; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 19 | $scratch =~ s/\#([^\#]+)\#/${$self}{$1}/g; # interpolate | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 19 | print $fh $scratch; | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 19 | ▶ | if ($tagname eq 'item-number') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | print $fh $token->attr('number'), ". \n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } elsif ($tagname eq 'item-bullet') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | print $fh "\\'", ord("_"), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | #for funky testing: print $fh '', rtf_esc(1, "\x{4E4B}\x{9053}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } elsif( $type eq 'end' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 22 | DEBUG > 1 and print STDERR " -$type ",$token->tagname,"\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 22 | ▶ | if( ($tagname = $token->tagname) =~ m/^over-/s ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | DEBUG and print STDERR "Indenting back $indent_stack[-1] twips.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->{'rtfindent'} -= pop @indent_stack; | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | pop @stack; | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | ▶ | } elsif( $tagname eq 'Verbatim' or $tagname eq 'VerbatimFormatted') { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$tagname eq "Verbatim" or $tagname eq "VerbatimFormatted"
MC/DC50%1/2
$tagname eq "Verbatim" or $tagname eq "VerbatimFormatted"
$tagname eq "Verbatim"
$tagname eq "VerbatimFormatted"
Truth table66%2/3
A or B
A= $tagname eq "Verbatim"B= $tagname eq "VerbatimFormatted"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | --$self->{'rtfverbatim'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 22 | ▶ | defined($scratch = $self->{'Tagmap'}{"/$tagname"}) or next; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $scratch =~ s/\#([^\#]+)\#/${$self}{$1}/g; # interpolate | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 19 | print $fh $scratch; | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | ▶ | sub do_beginning { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_beginning: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | my $fh = $self->{'output_fh'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 3 | return print $fh join '', | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | $self->doc_init, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | $self->font_table, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | $self->stylesheet, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | $self->color_table, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | $self->doc_info, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | $self->doc_start, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | ▶ | sub do_end { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | my $fh = $self->{'output_fh'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | return print $fh '}'; # that should do it | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 3 | ▶ | sub stylesheet { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stylesheet: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | return sprintf <<'END', | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | {\stylesheet | ||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | {\snext0 Normal;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | {\*\cs10 \additive Default Paragraph Font;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | {\*\cs16 \additive \i \sbasedon10 pod-I;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | {\*\cs17 \additive \i\lang1024\noproof \sbasedon10 pod-F;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | {\*\cs18 \additive \b \sbasedon10 pod-B;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | {\*\cs19 \additive \f1\lang1024\noproof\sbasedon10 pod-C;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | {\*\cs30 \additive \ul \sbasedon10 pod-U;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | {\s20\ql \li0\ri0\sa180\widctlpar\f1\fs%s\lang1024\noproof\sbasedon0 \snext0 pod-codeblock;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | {\*\cs21 \additive \lang1024\noproof \sbasedon10 pod-computerese;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | {\*\cs22 \additive \i\lang1024\noproof\sbasedon10 pod-L-pod;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | {\*\cs23 \additive \i\lang1024\noproof\sbasedon10 pod-L-url;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | {\*\cs24 \additive \i\lang1024\noproof\sbasedon10 pod-L-man;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | {\*\cs25 \additive \f1\lang1024\noproof\sbasedon0 pod-codelbock-plain;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | {\*\cs26 \additive \f1\lang1024\noproof\sbasedon25 pod-codelbock-ital;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | {\*\cs27 \additive \f1\lang1024\noproof\sbasedon25 pod-codelbock-bold;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | {\*\cs28 \additive \f1\lang1024\noproof\sbasedon25 pod-codelbock-bold-ital;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | {\s31\ql \keepn\sb90\sa180\f2\fs%s\ul\sbasedon0 \snext0 pod-head1;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | {\s32\ql \keepn\sb90\sa180\f2\fs%s\ul\sbasedon0 \snext0 pod-head2;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | {\s33\ql \keepn\sb90\sa180\f2\fs%s\ul\sbasedon0 \snext0 pod-head3;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | {\s34\ql \keepn\sb90\sa180\f2\fs%s\ul\sbasedon0 \snext0 pod-head4;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | END | ||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $_[0]->codeblock_halfpoint_size(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | $_[0]->head1_halfpoint_size(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | $_[0]->head2_halfpoint_size(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | $_[0]->head3_halfpoint_size(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | $_[0]->head4_halfpoint_size(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # Override these as necessary for further customization | ||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | ▶ | sub font_table { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
font_table: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | return <<'END'; # text font, code font, heading font | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | {\fonttbl | ||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | {\f0\froman Times New Roman;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | {\f1\fmodern Courier New;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | {\f2\fswiss Arial;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | END | ||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 3 | ▶ | sub doc_init { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doc_init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 3 | return <<'END'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | {\rtf1\ansi\deff0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | END | ||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 3 | ▶ | sub color_table { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color_table: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | return <<'END'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | {\colortbl;\red255\green0\blue0;\red0\green0\blue255;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | END | ||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | ▶ | sub doc_info { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doc_info: called CC=5 SCAR=21.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | my $tag = __PACKAGE__ . ' ' . $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | ▶ | unless($class eq __PACKAGE__) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $tag = " ($tag)"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | $tag = " v" . $self->VERSION . $tag if defined $self->VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $tag = $class . $tag; | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | return sprintf <<'END', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | {\info{\doccomm | ||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | %s | ||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | using %s v%s | ||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | under Perl v%s at %s GMT} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | {\author [see doc]}{\company [see doc]}{\operator [see doc]} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | END | ||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # None of the following things should need escaping, I dare say! | ||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | $tag, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | $ISA[0], $ISA[0]->VERSION(), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | ▶ | $], scalar(gmtime($ENV{SOURCE_DATE_EPOCH} || time)), | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'SOURCE_DATE_EPOCH'} || time
MC/DC0%0/1
$ENV{'SOURCE_DATE_EPOCH'} || time
$ENV{'SOURCE_DATE_EPOCH'}
Truth table50%1/2
A
A= $ENV{'SOURCE_DATE_EPOCH'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 3 | ▶ | sub doc_start { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doc_start: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 3 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 3 | my $title = $self->get_short_title(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 3 | DEBUG and print STDERR "Short Title: <$title>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 3 | ▶ | $title .= ' ' if length $title; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 3 | $title =~ s/ *$/ /s; | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 3 | $title =~ s/^ //s; | |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 3 | $title =~ s/ $/, /s; | |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # make sure it ends in a comma and a space, unless it's 0-length | ||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | my $is_obviously_module_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 3 | ▶ | $is_obviously_module_name = 1 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$title =~ /^\S+$/s and $title =~ /::/s
MC/DC0%0/2
$title =~ /^\S+$/s and $title =~ /::/s
$title =~ /^\S+$/s
$title =~ /::/s
Truth table33%1/3
A and B
A= $title =~ /^\S+$/sB= $title =~ /::/s
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | if $title =~ m/^\S+$/s and $title =~ m/::/s; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # catches the most common case, at least | ||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | DEBUG and print STDERR "Title0: <$title>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 3 | $title = rtf_esc(1, $title); # 1 => escape hyphen | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 3 | DEBUG and print STDERR "Title1: <$title>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 3 | ▶ | $title = '\lang1024\noproof ' . $title | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | if $is_obviously_module_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 3 | return sprintf <<'END', | |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | \deflang%s\plain\lang%s\widowctrl | ||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | {\header\pard\qr\plain\f2\fs%s | ||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | %s | ||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | p.\chpgn\par} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | \fs%s | ||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | END | ||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ($self->doc_lang) x 2, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | $self->header_halfpoint_size, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | $title, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | $self->normal_halfpoint_size, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | #------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 3 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 3 | my $question_mark_code_points = | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | Pod::Simple::BlackBox::my_qr('([^\x00-\x{D7FF}\x{E000}-\x{10FFFF}])', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | "\x{110000}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 3 | my $plane0 = | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | Pod::Simple::BlackBox::my_qr('([\x{100}-\x{FFFF}])', "\x{100}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 3 | my $other_unicode = | |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | Pod::Simple::BlackBox::my_qr('([\x{10000}-\x{10FFFF}])', "\x{10000}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 22 | ▶ | sub esc_uni($) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
esc_uni: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 3 | ▶ | use if do { no integer; "$]" <= 5.006002 }, 'utf8'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 22 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # The output is expected to be UTF-16. Surrogates and above-Unicode get | ||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # mapped to '?' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 22 | ▶ | $x =~ s/$question_mark_code_points/?/g if $question_mark_code_points; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # Non-surrogate Plane 0 characters get mapped to their code points. But | ||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # the standard calls for a 16bit SIGNED value. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 22 | ▶ | $x =~ s/$plane0/'\\uc1\\u'.((ord($1)<32768)?ord($1):(ord($1)-65536)).'?'/eg | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | if $plane0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # Use surrogate pairs for the rest | ||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 22 | ▶ | $x =~ s/$other_unicode/'\\uc1\\u' . ((ord($1) >> 10) + 0xD7C0 - 65536) . '\\u' . (((ord$1) & 0x03FF) + 0xDC00 - 65536) . '?'/eg if $other_unicode; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 22 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 22 | ▶ | sub rtf_esc ($$) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rtf_esc: called CC=6 SCAR=19.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # The parameter is true if we should escape hyphens | ||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 22 | ▶ | my $escape_re = ((shift) ? $escaped : $escaped_sans_hyphen); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | # When false, it doesn't change "-" to hard-hyphen. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # We don't want to change the "-" to hard-hyphen, because we want to | ||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # be able to paste this into a file and run it without there being | ||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # dire screaming about the mysterious hard-hyphen character (which | ||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # looks just like a normal dash character). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | # XXX The comments used to claim that when false it didn't apply computerese | ||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # style-smarts, but khw didn't see this actually | ||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 22 | my $x; # scratch | |||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 22 | ▶ | if(!defined wantarray) { # void context: alter in-place! | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 19 | for(@_) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 19 | s/($escape_re)/$Escape{$1}/g; # ESCAPER | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 19 | $_ = esc_uni($_); | |||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 19 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } elsif(wantarray) { # return an array | ||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | return map {; ($x = $_) =~ | |||||||||||||||||||||||||||||||||||||||||||||||
| 594 | s/($escape_re)/$Escape{$1}/g; # ESCAPER | ||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $x = esc_uni($x); | |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $x; | |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } else { # return a single scalar | ||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 3 | ▶ | ($x = ((@_ == 1) ? $_[0] : join '', @_) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | ) =~ s/($escape_re)/$Escape{$1}/g; # ESCAPER | ||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # Escape \, {, }, -, control chars, and 7f-ff. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 3 | $x = esc_uni($x); | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 3 | return $x; | |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||