| 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Pod::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | require Pod::PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Pod::Rtf; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | @ISA = qw(Pod::Parser); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | sub begin_input { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_input: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | my $parser = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my $header = <<"EOHEADER"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | {\\rtf1\\ansi \\deff0\\deflang1024 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | {\\fonttbl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | {\\f0\\froman Times New Roman;} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | {\\f1\\fmodern Fixedsys;} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | {\\colortbl; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | \\red0\\green0\\blue0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | \\red0\\green0\\blue255; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | \\red0\\green255\\blue0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | \\red255\\green0\\blue0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | \\red255\\green255\\blue255; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | EOHEADER | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | if ($pound_note) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | $pound_note = context_string($pound_note); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | $header .= "#{\\footnote $pound_note}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | push(@pound_pages,$pound_note); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | if ($dollar_note) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | $header .= "\${\\footnote $dollar_note}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | push(@index_pages,$dollar_note); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | if ($K_note) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | $header .= "K{\\footnote $K_note}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | push(@K_pages,$dollar_note); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | $header .= "\n{\\pard}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my $out_fh = $parser->output_handle(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | print $out_fh $header; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 28 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=19 SCAR=32.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 28 | my ($parser, $command, $paragraph, $line_num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 28 | my $cmd_open = "{"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 28 | my $cmd_close = "}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 28 | ▶ | if ($command eq 'head1') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | my $line = $paragraph; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | $line = context_string("$pound_note$line"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | if (length($line) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | push(@pound_topics,$line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | $cmd_open = "#{\\footnote $line}\n$cmd_open\\f0\\fs36 "; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | $cmd_close .= "{\\par}{\\pard}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | elsif ($command eq 'head2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | my $line = $paragraph; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | $line = context_string("$pound_note$line"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | if (length($line) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | push(@pound_topics,$line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | $cmd_open = "#{\\footnote $line}\n$cmd_open\\f0\\fs28 "; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | $cmd_close .= "{\\par}{\\pard}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | elsif ($command =~ /head[3-9]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | my $line = $paragraph; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | $line = context_string("$pound_note$line"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | if (length($line) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | push(@pound_topics,$line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | $cmd_open = "#{\\footnote $line}\n$cmd_open\\f0\\fs24 "; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $cmd_close .= "{\\par}{\\pard}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | elsif ($command eq 'item') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 7 | my $non_space = $paragraph; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | $non_space =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($non_space eq '*') { $paragraph =~ s/\*/\\bullet/; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # HCW on NT seems to have difficulty w/ RTF, we hack around: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | ▶ | if ($is_first_item eq "yes") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 6 | $cmd_open =~ s/\{//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 6 | $is_first_item = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif ($command eq 'over') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | my $amount = $paragraph; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($amount !~ s/(\d+)/$1/) { $amount = 4 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # @10 pt fontw/ 2:1 aspect: 5 pts/space * 20 twips/point | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 6 | $amount *= 100; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | $paragraph = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 6 | $li = "\\li$amount"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | $cmd_open = "$cmd_open$li\\f0\\fs20"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # HCW on NT seems to have difficulty w/ RTF, we hack around: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 6 | $cmd_close =~ s/\}//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | $is_first_item = "yes"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | elsif ($command eq 'back') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 6 | $cmd_close = "{\\par}{\\pard}$cmd_close"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | elsif ($command eq 'cut') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | elsif ($command eq 'pod') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # perhaps for and begin ought to be handled as verbatim(?) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | elsif ($command eq 'for') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $li = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | elsif ($command eq 'begin') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | elsif ($command eq 'end') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ## ... other commands and their actions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | warn "Unrecognized command '$command'\n" if $VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 28 | my $expansion = $parser->interpolate($paragraph, $line_num); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 28 | $expansion = "$cmd_open$expansion$cmd_close"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 28 | my $out_fh = $parser->output_handle(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 28 | print $out_fh $expansion; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 4 | ▶ | sub verbatim { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbatim: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 4 | my ($parser, $paragraph, $line_num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ## Format verbatim paragraph; sample actions might be: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | my @lines = split(/\n/,$paragraph); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | my $out_fh = $parser->output_handle(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | foreach my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | chomp($line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | $line = rtf_escape($line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | $line = "{{\\keep}\\f1\\fs20 $line {\\line}}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | print $out_fh $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | $line="{\\par}{\\pard}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | print $out_fh $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | ▶ | sub textblock { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
textblock: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | my ($parser, $paragraph, $line_num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ## Translate/Format this block of text; sample actions might be: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # Because we do the rtf escape here it is not necessary to do it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # for the interior sequences individually. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 4 | my $rtf_paragraph = rtf_escape($paragraph); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | my $expansion = $parser->interpolate($rtf_paragraph, $line_num); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | my $rtf_par = "{$li\\f0\\fs20\n$expansion\{\\par}}\n{\\par}{\\pard}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | my $out_fh = $parser->output_handle(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | print $out_fh $rtf_par; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 18 | ▶ | sub interior_sequence { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interior_sequence: called CC=22 SCAR=44.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 18 | my ($parser, $seq_command, $argument) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 18 | my $cfont = '\\f1'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 18 | my $cfonts = '\\fs20'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # rtf escape has already been done by textblock | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # my $argument = rtf_escape($seq_argument); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ## Expand an interior sequence; sample actions might be: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 18 | ▶ | return "{\\i $argument}" if ($seq_command eq 'I'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 16 | ▶ | return "{\\b $argument}" if ($seq_command eq 'B'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 13 | ▶ | return "{{\\keep} $argument{\\pard}}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | if ($seq_command eq 'S'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 13 | ▶ | return "{$cfont$cfonts $argument}{\\pard}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | if ($seq_command eq 'C'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 11 | ▶ | if ($seq_command eq 'L') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | my @links = split(/\|/,$argument); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | my $show = $argument; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | if ($#links >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $show = $links[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $argument = join('|',@links[1..$#links]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | ▶ | if ($argument =~ /\/?\"[^\"\|\/]+\"/) { # an L<"sec"> or L</"sec"> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | my $vlink = context_string("$pound_note$argument"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | return "{\\strike $show}{\\v $vlink}" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ($argument =~ /[^\"\|\/]+/) { # an L<name> or L<sec> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $vlink = context_string($argument); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # *if* we have seen it before: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if (scalar(grep(/$vlink/,@pound_topics))) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $vlink = context_string("$pound_note$vlink"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | elsif (scalar(grep(/$vlink/,@pound_pages))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ($vlink !~ /\./) { $vlink .= ".pod"; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ($vlink !~ /\./) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($vlink =~ /perl/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $vlink .= ".pod"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | elsif ($argument =~ /::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $vlink .= ".pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | return "{\\strike $show}{\\v $vlink}" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # if (($argument !~ /\//) || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # ($argument !~ /\|/)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | #if ( m{^ ([a-zA-Z][^\s\/]+) (\([^\)]+\))? $}x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # ## LREF: a manpage(3f) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # $_ = "the $1$2 manpage"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | #elsif ( m{^ ([^/]+) / ([:\w]+(\(\))?) $}x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # ## LREF: an =item on another manpage | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # $_ = "the \"$2\" entry in the $1 manpage"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | #elsif ( m{^ / ([:\w]+(\(\))?) $}x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # ## LREF: an =item on this manpage | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # $_ = $self->internal_lrefs($1); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | #elsif ( m{^ (?: ([a-zA-Z]\S+?) / )? "?(.*?)"? $}x ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # ## LREF: a =head2 (head1?), maybe on a manpage, maybe right here | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # ## the "func" can disambiguate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # $_ = ((defined $1) && $1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # ? "the section on \"$2\" in the $1 manpage" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # : "the section on \"$2\""; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 9 | ▶ | return "$argument" if ($seq_command eq 'F'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 7 | ▶ | if ($seq_command eq 'X') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return "{\\strike $argument}{\\v $argument}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 7 | ▶ | return "$argument" if ($seq_command eq 'Z'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 6 | ▶ | if ($seq_command eq 'E') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 6 | ▶ | if (defined($Pod::PlainText::HTML_Escapes{$argument})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | return "$Pod::PlainText::HTML_Escapes{$argument}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 6 | ▶ | warn "Unrecognized escape sequence '$seq_command<$argument>'\n" if $VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 6 | return "$argument"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ## ... other sequence commands and their resulting text | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | warn "Unrecognized interior sequence '$seq_command<$argument>'\n" if $VERBOSE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | return "$argument"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | sub end_input { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_input: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | my $parser = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | my $footer = <<"EOFOOTER"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | EOFOOTER | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | my $out_fh = $parser->output_handle(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | print $out_fh $footer; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 9 | ▶ | sub rtf_escape { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rtf_escape: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 9 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # According to Keith Bugg we need to \ escape \ {} [] # $ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # Experience with HCW on NT 4 shows that only \ {} need be escaped. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 9 | $text =~ s/(\\)/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 9 | $text =~ s/(\{)/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 9 | $text =~ s/(\})/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | return($text); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | sub context_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | my $text = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $text =~ s/[^A-Za-z0-9_\.]//g; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | if (length($text) > 255) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | return(substr($text,0,255)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | return($text); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 12 | ▶ | sub context_string { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context_string: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 12 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 12 | $text =~ s/[^A-Za-z0-9_\.]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 12 | ▶ | if (length($text) > 255) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return(substr($text,0,255)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 12 | return($text); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | pod2rtf | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | pod2rtf podfile [> podfile.rtf] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | This script incorporateds the Pod::Rtf module and invokes it fon input files, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | L<perl>. L<Pod::Rtf>, E<amp> L<"DESCRIPTION"> for further detail. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | The indentation for lists requires an =over and is a bit of a kludge. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | For some reason yumlaut (\xFF) does not seem to render iunder the fonts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | used here. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | Peter Prymmer. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | Copyright (c) 1999 Peter Prymmer. This code may be distributed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ## Create a parser object and have it parse file whose name was | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ## given on the command-line (use STDIN if no files were given). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | my $parser = new Pod::Rtf(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | $parser->parse_from_filehandle(\*STDIN) if (@ARGV == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | for (@ARGV) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | my $file = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | $file =~ s/\..*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | $Pod::Rtf::pound_note = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | $Pod::Rtf::dollar_note = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | $Pod::Rtf::K_note = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | $parser->parse_from_file($_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||