| 1 | package Pod::XML; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | # $Id: XML.pm 30 2007-02-03 16:50:07Z matt $ | ||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use vars qw(@ISA $VERSION); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Pod::Parser; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 5 | @ISA = ( 'Pod::Parser' ); | |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 5 | $VERSION = '0.99'; | |||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | # I'm not sure why Matt Sergeant did this in this way but I'll leave it for | ||||||||||||||||||||||||||||||||||||||
| 16 | # the time being | ||||||||||||||||||||||||||||||||||||||
| 17 | 5 | my %head2sect = ( | |||||||||||||||||||||||||||||||||||||
| 18 | 1 => "sect1", | ||||||||||||||||||||||||||||||||||||||
| 19 | 2 => "sect2", | ||||||||||||||||||||||||||||||||||||||
| 20 | 3 => "sect3", | ||||||||||||||||||||||||||||||||||||||
| 21 | 4 => "sect4", | ||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | # a hash array of HTML escape codes | ||||||||||||||||||||||||||||||||||||||
| 25 | 5 | my %HTML_Escapes = ( | |||||||||||||||||||||||||||||||||||||
| 26 | "apos" => "#x27", # apostrophe | ||||||||||||||||||||||||||||||||||||||
| 27 | "Aacute" => "#xC1", # capital A, acute accent | ||||||||||||||||||||||||||||||||||||||
| 28 | "aacute" => "#xE1", # small a, acute accent | ||||||||||||||||||||||||||||||||||||||
| 29 | "Acirc" => "#xC2", # capital A, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 30 | "acirc" => "#xE2", # small a, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 31 | "AElig" => "#xC6", # capital AE diphthong (ligature) | ||||||||||||||||||||||||||||||||||||||
| 32 | "aelig" => "#xE6", # small ae diphthong (ligature) | ||||||||||||||||||||||||||||||||||||||
| 33 | "Agrave" => "#xC0", # capital A, grave accent | ||||||||||||||||||||||||||||||||||||||
| 34 | "agrave" => "#xE0", # small a, grave accent | ||||||||||||||||||||||||||||||||||||||
| 35 | "Aring" => "#xC5", # capital A, ring | ||||||||||||||||||||||||||||||||||||||
| 36 | "aring" => "#xE5", # small a, ring | ||||||||||||||||||||||||||||||||||||||
| 37 | "Atilde" => "#xC3", # capital A, tilde | ||||||||||||||||||||||||||||||||||||||
| 38 | "atilde" => "#xE3", # small a, tilde | ||||||||||||||||||||||||||||||||||||||
| 39 | "Auml" => "#xC4", # capital A, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 40 | "auml" => "#xE4", # small a, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 41 | "Ccedil" => "#xC7", # capital C, cedilla | ||||||||||||||||||||||||||||||||||||||
| 42 | "ccedil" => "#xE7", # small c, cedilla | ||||||||||||||||||||||||||||||||||||||
| 43 | "Eacute" => "#xC9", # capital E, acute accent | ||||||||||||||||||||||||||||||||||||||
| 44 | "eacute" => "#xE9", # small e, acute accent | ||||||||||||||||||||||||||||||||||||||
| 45 | "Ecirc" => "#xCA", # capital E, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 46 | "ecirc" => "#xEA", # small e, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 47 | "Egrave" => "#xC8", # capital E, grave accent | ||||||||||||||||||||||||||||||||||||||
| 48 | "egrave" => "#xE8", # small e, grave accent | ||||||||||||||||||||||||||||||||||||||
| 49 | "ETH" => "#xD0", # capital Eth, Icelandic | ||||||||||||||||||||||||||||||||||||||
| 50 | "eth" => "#xF0", # small eth, Icelandic | ||||||||||||||||||||||||||||||||||||||
| 51 | "Euml" => "#xCB", # capital E, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 52 | "euml" => "#xEB", # small e, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 53 | "Iacute" => "#xCD", # capital I, acute accent | ||||||||||||||||||||||||||||||||||||||
| 54 | "iacute" => "#xED", # small i, acute accent | ||||||||||||||||||||||||||||||||||||||
| 55 | "Icirc" => "#xCE", # capital I, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 56 | "icirc" => "#xEE", # small i, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 57 | "Igrave" => "#xCD", # capital I, grave accent | ||||||||||||||||||||||||||||||||||||||
| 58 | "igrave" => "#xED", # small i, grave accent | ||||||||||||||||||||||||||||||||||||||
| 59 | "Iuml" => "#xCF", # capital I, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 60 | "iuml" => "#xEF", # small i, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 61 | "Ntilde" => "#xD1", # capital N, tilde | ||||||||||||||||||||||||||||||||||||||
| 62 | "ntilde" => "#xF1", # small n, tilde | ||||||||||||||||||||||||||||||||||||||
| 63 | "Oacute" => "#xD3", # capital O, acute accent | ||||||||||||||||||||||||||||||||||||||
| 64 | "oacute" => "#xF3", # small o, acute accent | ||||||||||||||||||||||||||||||||||||||
| 65 | "Ocirc" => "#xD4", # capital O, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 66 | "ocirc" => "#xF4", # small o, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 67 | "Ograve" => "#xD2", # capital O, grave accent | ||||||||||||||||||||||||||||||||||||||
| 68 | "ograve" => "#xF2", # small o, grave accent | ||||||||||||||||||||||||||||||||||||||
| 69 | "Oslash" => "#xD8", # capital O, slash | ||||||||||||||||||||||||||||||||||||||
| 70 | "oslash" => "#xF8", # small o, slash | ||||||||||||||||||||||||||||||||||||||
| 71 | "Otilde" => "#xD5", # capital O, tilde | ||||||||||||||||||||||||||||||||||||||
| 72 | "otilde" => "#xF5", # small o, tilde | ||||||||||||||||||||||||||||||||||||||
| 73 | "Ouml" => "#xD6", # capital O, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 74 | "ouml" => "#xF6", # small o, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 75 | "szlig" => "#xDF", # small sharp s, German (sz ligature) | ||||||||||||||||||||||||||||||||||||||
| 76 | "THORN" => "#xDE", # capital THORN, Icelandic | ||||||||||||||||||||||||||||||||||||||
| 77 | "thorn" => "#xFE", # small thorn, Icelandic | ||||||||||||||||||||||||||||||||||||||
| 78 | "Uacute" => "#xDA", # capital U, acute accent | ||||||||||||||||||||||||||||||||||||||
| 79 | "uacute" => "#xFA", # small u, acute accent | ||||||||||||||||||||||||||||||||||||||
| 80 | "Ucirc" => "#xDB", # capital U, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 81 | "ucirc" => "#xFB", # small u, circumflex accent | ||||||||||||||||||||||||||||||||||||||
| 82 | "Ugrave" => "#xD9", # capital U, grave accent | ||||||||||||||||||||||||||||||||||||||
| 83 | "ugrave" => "#xF9", # small u, grave accent | ||||||||||||||||||||||||||||||||||||||
| 84 | "Uuml" => "#xDC", # capital U, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 85 | "uuml" => "#xFC", # small u, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 86 | "Yacute" => "#xDD", # capital Y, acute accent | ||||||||||||||||||||||||||||||||||||||
| 87 | "yacute" => "#xFD", # small y, acute accent | ||||||||||||||||||||||||||||||||||||||
| 88 | "yuml" => "#xFF", # small y, dieresis or umlaut mark | ||||||||||||||||||||||||||||||||||||||
| 89 | "lchevron" => "#xAB", # left chevron (double less than) | ||||||||||||||||||||||||||||||||||||||
| 90 | "rchevron" => "#xBB", # right chevron (double greater than) | ||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | sub html_escape | ||||||||||||||||||||||||||||||||||||||
| 94 | 21 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
html_escape: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 95 | 21 | ▶ | my $text = shift || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | # ampersand MUST be done first! | ||||||||||||||||||||||||||||||||||||||
| 98 | 21 | $text =~ s/&/\&/g; | |||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||
| 100 | # handle < and > too | ||||||||||||||||||||||||||||||||||||||
| 101 | 21 | $text =~ s/</\</g; | |||||||||||||||||||||||||||||||||||||
| 102 | 21 | $text =~ s/>/\>/g; | |||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | # convert other {tag:...} markers | ||||||||||||||||||||||||||||||||||||||
| 105 | 21 | $text =~ s/{tag:escape ref='([^']*)'}/\&$1;/g; | |||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||
| 107 | 21 | return $text; | |||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||
| 110 | sub finalise_output | ||||||||||||||||||||||||||||||||||||||
| 111 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
finalise_output: called CC=4 SCAR=15.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 112 | 4 | my $parser = shift; | |||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||
| 114 | # put something pretty together | ||||||||||||||||||||||||||||||||||||||
| 115 | $parser->{xml_string} = | ||||||||||||||||||||||||||||||||||||||
| 116 | "<?xml version='1.0' encoding='" . | ||||||||||||||||||||||||||||||||||||||
| 117 | ( $parser->{Encoding} || "iso-8859-1" ) . "'?>\n" . | ||||||||||||||||||||||||||||||||||||||
| 118 | "<pod xmlns=\"http://axkit.org/ns/2000/pod2xml\">\n" . | ||||||||||||||||||||||||||||||||||||||
| 119 | "<head>\n" . | ||||||||||||||||||||||||||||||||||||||
| 120 | "<title>" . html_escape ( $parser->{title} ) . "</title>\n" . | ||||||||||||||||||||||||||||||||||||||
| 121 | "</head>\n" . | ||||||||||||||||||||||||||||||||||||||
| 122 | $parser->{xml_string} . | ||||||||||||||||||||||||||||||||||||||
| 123 | 4 | ▶ | "</pod>\n"; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parser->{'Encoding'} || 'iso-8859-1'
MC/DC0%0/1
$parser->{'Encoding'} || 'iso-8859-1'
$parser->{'Encoding'}
Truth table50%1/2
A
A= $parser->{'Encoding'}
| |||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | if ( $parser->{Encoding} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $tmp = Encode::encode ( $parser->{Encoding}, $parser->{xml_string} ); | |||||||||||||||||||||||||||||||||||||
| 128 | 0 | $parser->{xml_string} = $tmp; | |||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||
| 131 | 4 | ▶ | if ( ! $parser->{send_to_string} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||
| 133 | 4 | my $fh = $parser->output_handle (); | |||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | 4 | print $fh $parser->{xml_string}; | |||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | sub xml_output | ||||||||||||||||||||||||||||||||||||||
| 140 | 21 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
xml_output: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 141 | 21 | my ( $parser, @strings ) = @_; | |||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||
| 143 | 21 | $parser->{xml_string} .= join ( '', @strings ); | |||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||
| 146 | sub begin_pod | ||||||||||||||||||||||||||||||||||||||
| 147 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_pod: called CC=4 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 148 | 4 | my ( $parser ) = @_; | |||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||
| 150 | 4 | ▶ | if ( $parser->{Encoding} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||
| 152 | # can we use the Encode module? | ||||||||||||||||||||||||||||||||||||||
| 153 | eval | ||||||||||||||||||||||||||||||||||||||
| 154 | 0 | { | |||||||||||||||||||||||||||||||||||||
| 155 | 0 | require Encode; | |||||||||||||||||||||||||||||||||||||
| 156 | }; | ||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | die ( "Need Encode module to specify specific output encoding - " . $@ ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 159 | if ( $@ ); | ||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||
| 161 | # make sure we can encode to the specific encoding | ||||||||||||||||||||||||||||||||||||||
| 162 | eval | ||||||||||||||||||||||||||||||||||||||
| 163 | 0 | { | |||||||||||||||||||||||||||||||||||||
| 164 | 0 | Encode::encode ( $parser->{Encoding}, "" ); | |||||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | die ( "Encoding issue - " . $@ ) if ( $@ ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||
| 170 | 4 | $parser->{headlevel} = 0; | |||||||||||||||||||||||||||||||||||||
| 171 | 4 | $parser->{seentitle} = 0; | |||||||||||||||||||||||||||||||||||||
| 172 | 4 | $parser->{closeitem} = 0; | |||||||||||||||||||||||||||||||||||||
| 173 | 4 | $parser->{in_begin_block} = 0; | |||||||||||||||||||||||||||||||||||||
| 174 | 4 | $parser->{this_is_name} = 0; | |||||||||||||||||||||||||||||||||||||
| 175 | 4 | $parser->{title} = ''; | |||||||||||||||||||||||||||||||||||||
| 176 | 4 | $parser->{xml_string} = ''; | |||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||
| 179 | sub end_pod | ||||||||||||||||||||||||||||||||||||||
| 180 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
end_pod: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 181 | 4 | my ( $parser ) = @_; | |||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||
| 183 | 4 | ▶ | while ( $parser->{headlevel} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||||||||||||
| 185 | 4 | $parser->xml_output ( "</" . $head2sect { $parser->{headlevel}-- } . | |||||||||||||||||||||||||||||||||||||
| 186 | ">\n" ); | ||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||
| 189 | 4 | $parser->finalise_output; | |||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | sub command | ||||||||||||||||||||||||||||||||||||||
| 193 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=17 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 194 | 8 | my ( $parser, $command, $paragraph ) = @_; | |||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | 8 | $paragraph =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||
| 197 | 8 | $paragraph =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||
| 199 | 8 | $paragraph = $parser->interpolate ( $paragraph ); | |||||||||||||||||||||||||||||||||||||
| 200 | 8 | $paragraph = uri_find ( $paragraph ); | |||||||||||||||||||||||||||||||||||||
| 201 | 8 | $paragraph = html_escape ( $paragraph ); | |||||||||||||||||||||||||||||||||||||
| 202 | 8 | $paragraph =~ s/\{(\/?)tag:(.*?)\}/<$1$2>/g; | |||||||||||||||||||||||||||||||||||||
| 203 | 8 | $paragraph =~ s/\{code:(\d+)\}/&#$1/g; | |||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||
| 205 | 8 | ▶ | if ( $parser->{in_begin_block} == 0 ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||||||||||
| 207 | 7 | ▶ | if ( $command =~ /^head(\d+)/ ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||
| 209 | 6 | my $headlevel = $1; | |||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||
| 211 | # we should use "NAME" as the title | ||||||||||||||||||||||||||||||||||||||
| 212 | $parser->{this_is_name}++ | ||||||||||||||||||||||||||||||||||||||
| 213 | 6 | ▶ | if ( $paragraph =~ m/^name$/i && $parser->{this_is_name} == 0 ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$paragraph =~ /^name$/i and $parser->{"this_is_name"} == 0
MC/DC100%2/2
$paragraph =~ /^name$/i and $parser->{"this_is_name"} == 0
$paragraph =~ /^name$/i
$parser->{"this_is_name"} == 0
Truth table100%3/3
A and B
A= $paragraph =~ /^name$/iB= $parser->{"this_is_name"} == 0
| |||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||
| 215 | 6 | ▶ | if ( $headlevel <= $parser->{headlevel} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | while ( $headlevel <= $parser->{headlevel} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||
| 219 | 2 | $parser->xml_output ( "</", $head2sect { $parser->{headlevel}-- }, | |||||||||||||||||||||||||||||||||||||
| 220 | ">\n" ); | ||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||
| 224 | 6 | ▶ | while ( $headlevel > ( $parser->{headlevel} + 1 ) ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||
| 226 | $parser->xml_output ( "<", $head2sect { ++$parser->{headlevel} }, | ||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ">\n" ); | |||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||
| 230 | 6 | $parser->{headlevel} = $headlevel; | |||||||||||||||||||||||||||||||||||||
| 231 | 6 | $parser->xml_output ( "<", $head2sect { $headlevel }, ">\n", | |||||||||||||||||||||||||||||||||||||
| 232 | "<title>", $paragraph, "</title>\n" ); | ||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||
| 234 | elsif ( $command eq "over" ) | ||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ( $parser->{closeitem} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $parser->xml_output ( "</item>\n" ); | |||||||||||||||||||||||||||||||||||||
| 239 | 0 | $parser->{closeitem} = 0; | |||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $parser->xml_output ( "<list>\n" ); | |||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||
| 244 | elsif ( $command eq "back" ) | ||||||||||||||||||||||||||||||||||||||
| 245 | { | ||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ( $parser->{closeitem} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $parser->xml_output ( "</item>\n" ); | |||||||||||||||||||||||||||||||||||||
| 249 | 0 | $parser->{closeitem} = 0; | |||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $parser->xml_output ( "</list>\n" ); | |||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||
| 254 | elsif ( $command eq "item" ) | ||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ( $parser->{closeitem} ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $parser->xml_output ( "</item>\n" ); | |||||||||||||||||||||||||||||||||||||
| 259 | 0 | $parser->{closeitem} = 0; | |||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $parser->xml_output ( "<item>" ); | |||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if ( $paragraph ne '*' ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $paragraph =~ s/^\*\s+//; | |||||||||||||||||||||||||||||||||||||
| 267 | 0 | $parser->xml_output ( "<itemtext>", $paragraph, "</itemtext>\n" ); | |||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $parser->{closeitem}++; | |||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||
| 272 | elsif ( $command eq 'begin' ) | ||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||
| 274 | # this is to strip out =begin ... =end blocks, which aren't generally POD | ||||||||||||||||||||||||||||||||||||||
| 275 | 1 | $parser->{in_begin_block} = 1; | |||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||
| 278 | elsif ( $command eq 'end' ) | ||||||||||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||||||||||
| 280 | 1 | $parser->{in_begin_block} = 0; | |||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||
| 284 | sub verbatim | ||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
verbatim: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my ( $parser, $paragraph ) = @_; | |||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | return if $parser->{in_begin_block}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ( $paragraph =~ s/^(\s*)// ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $indent = $1; | |||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $paragraph =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return unless length $paragraph; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $paragraph =~ s/^$indent//mg; # un-indent | |||||||||||||||||||||||||||||||||||||
| 299 | 0 | $paragraph =~ s/\]\]>/\]\]>\]\]><!\[CDATA\[/g; | |||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||
| 301 | # is this the title block? | ||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if ( $parser->{this_is_name} == 1 ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||||||
| 304 | # increment, rather than setting back to zero; this way we can ensure | ||||||||||||||||||||||||||||||||||||||
| 305 | # the first NAME is used, but not proceeding ones | ||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $parser->{this_is_name}++; | |||||||||||||||||||||||||||||||||||||
| 307 | 0 | $parser->{title} = "<![CDATA[\n" . $paragraph . "\n]]>"; | |||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $parser->xml_output ( "<verbatim><![CDATA[\n", $paragraph, | |||||||||||||||||||||||||||||||||||||
| 311 | "\n]]></verbatim>\n" ); | ||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||
| 315 | sub textblock | ||||||||||||||||||||||||||||||||||||||
| 316 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
textblock: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 317 | 10 | my ( $parser, $paragraph, $line_num ) = @_; | |||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||
| 319 | 10 | ▶ | return if $parser->{in_begin_block}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||
| 321 | 9 | $paragraph =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||
| 322 | 9 | $paragraph =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||
| 324 | 9 | my $text = $parser->interpolate ( $paragraph ); | |||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||
| 326 | 9 | $text = uri_find ( $text ); | |||||||||||||||||||||||||||||||||||||
| 327 | 9 | $text = html_escape ( $text ); | |||||||||||||||||||||||||||||||||||||
| 328 | 9 | $text =~ s/\{(\/?)tag:(.*?)\}/<$1$2>/g; | |||||||||||||||||||||||||||||||||||||
| 329 | 9 | $text =~ s/\{code:(\d+)\}/&#$1/g; | |||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | 9 | ▶ | if ( $parser->{this_is_name} == 1 ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 332 | { | ||||||||||||||||||||||||||||||||||||||
| 333 | # increment, rather than setting back to zero; this way we can ensure the | ||||||||||||||||||||||||||||||||||||||
| 334 | # first NAME is used, but not proceeding ones | ||||||||||||||||||||||||||||||||||||||
| 335 | 2 | $parser->{this_is_name}++; | |||||||||||||||||||||||||||||||||||||
| 336 | 2 | $parser->{title} = $paragraph; | |||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||
| 339 | 9 | ▶ | if ( $parser->{headlevel} == 0 ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||||||||
| 341 | $parser->xml_output ( "<sect1>\n<title>", $parser->{title}, | ||||||||||||||||||||||||||||||||||||||
| 342 | 0 | "</title>\n" ); | |||||||||||||||||||||||||||||||||||||
| 343 | 0 | $parser->{headlevel}++; | |||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||
| 346 | 9 | $parser->xml_output ( "<para>\n", $text, "\n</para>\n" ); | |||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||
| 349 | sub uri_find | ||||||||||||||||||||||||||||||||||||||
| 350 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_find: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 351 | 17 | ▶ | my $text = shift || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||
| 353 | # Code from the Perl Cookbook | ||||||||||||||||||||||||||||||||||||||
| 354 | 17 | my $urls = '(https|http|telnet|gopher|file|wais|ftp|mailto)'; | |||||||||||||||||||||||||||||||||||||
| 355 | 17 | my $ltrs = '\w'; | |||||||||||||||||||||||||||||||||||||
| 356 | 17 | my $gunk = '/#~:.?+=&%@!\-'; | |||||||||||||||||||||||||||||||||||||
| 357 | 17 | my $punc = '.:?\-!,'; | |||||||||||||||||||||||||||||||||||||
| 358 | 17 | my $any = $ltrs . $gunk . $punc; | |||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||
| 360 | 17 | my $new; | |||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||
| 362 | 17 | ▶ | while ( | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 363 | $text =~ m{ | ||||||||||||||||||||||||||||||||||||||
| 364 | \G # anchor to last match place | ||||||||||||||||||||||||||||||||||||||
| 365 | (.*?) # catch stuff before match in $1 | ||||||||||||||||||||||||||||||||||||||
| 366 | \b # start at word boundary | ||||||||||||||||||||||||||||||||||||||
| 367 | ( # BEGIN $2 | ||||||||||||||||||||||||||||||||||||||
| 368 | $urls : # http: | ||||||||||||||||||||||||||||||||||||||
| 369 | (?![:/]) # negative lookahead for : or / | ||||||||||||||||||||||||||||||||||||||
| 370 | [$any]+? # followed by 1 or more allowed charact | ||||||||||||||||||||||||||||||||||||||
| 371 | ) # END $2 | ||||||||||||||||||||||||||||||||||||||
| 372 | (?= # look ahead after $2 | ||||||||||||||||||||||||||||||||||||||
| 373 | [$punc]* # for 0 or more punctuation characters | ||||||||||||||||||||||||||||||||||||||
| 374 | ( | ||||||||||||||||||||||||||||||||||||||
| 375 | [^$any] # followed by a non-URL character | ||||||||||||||||||||||||||||||||||||||
| 376 | | \Z # or alternatively the end of the html | ||||||||||||||||||||||||||||||||||||||
| 377 | ) | ||||||||||||||||||||||||||||||||||||||
| 378 | ) # end of look ahead | ||||||||||||||||||||||||||||||||||||||
| 379 | }igcsox ) | ||||||||||||||||||||||||||||||||||||||
| 380 | { | ||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ( $pre, $url ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||
| 382 | 0 | $new .= $pre; | |||||||||||||||||||||||||||||||||||||
| 383 | 0 | $new .= "\{tag:xlink uri='" . $url . "'\}" . $url . "\{/tag:xlink\}"; | |||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||
| 386 | 17 | $text =~ /\G(.*)/gcs; | |||||||||||||||||||||||||||||||||||||
| 387 | 17 | ▶ | $new .= $1 if defined $1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||
| 389 | 17 | return $new; | |||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||
| 392 | sub interior_sequence | ||||||||||||||||||||||||||||||||||||||
| 393 | 31 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
interior_sequence: called CC=19 SCAR=31.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 394 | 31 | my ( $parser, $seq_command, $seq_argument ) = @_; | |||||||||||||||||||||||||||||||||||||
| 395 | 31 | my $fh = $parser->output_handle (); | |||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||
| 397 | 31 | ▶ | if ( $seq_command eq 'C' ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 398 | { | ||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return "\{tag:code\}" . $seq_argument . "\{\/tag:code\}"; | |||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||
| 401 | elsif ( $seq_command eq 'I' ) | ||||||||||||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||||||||||||
| 403 | 0 | return "\{tag:emphasis\}" . $seq_argument . "\{\/tag:emphasis\}"; | |||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||
| 405 | elsif ( $seq_command eq 'B' ) | ||||||||||||||||||||||||||||||||||||||
| 406 | { | ||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return "\{tag:strong\}" . $seq_argument . "\{\/tag:strong\}"; | |||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||
| 409 | elsif ( $seq_command eq 'S' ) | ||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $seq_argument =~ s/ /\{char:160\}/g; | |||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||
| 413 | 0 | return $seq_argument; | |||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||
| 415 | elsif ( $seq_command eq 'F' ) | ||||||||||||||||||||||||||||||||||||||
| 416 | { | ||||||||||||||||||||||||||||||||||||||
| 417 | 0 | return "\{tag:filename\}" . $seq_argument . "\{\/tag:filename\}"; | |||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||
| 419 | elsif ( $seq_command eq 'X' ) | ||||||||||||||||||||||||||||||||||||||
| 420 | { | ||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return "\{tag:index\}" . $seq_argument . "\{\/tag:index\}"; | |||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||
| 423 | elsif ( $seq_command eq 'L' ) | ||||||||||||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||||||||||||
| 425 | # parse L<>, can be any of: | ||||||||||||||||||||||||||||||||||||||
| 426 | # L<name> or L<sect> (other page or section in this page) | ||||||||||||||||||||||||||||||||||||||
| 427 | # L<name/ident> (item in a other page) | ||||||||||||||||||||||||||||||||||||||
| 428 | # L<name/"sect"> (section in other page) | ||||||||||||||||||||||||||||||||||||||
| 429 | # L<"sect"> (same as L<sect>) | ||||||||||||||||||||||||||||||||||||||
| 430 | # L</"sect"> (same as L<sect>) | ||||||||||||||||||||||||||||||||||||||
| 431 | # L</sect> (same as L<sect>) | ||||||||||||||||||||||||||||||||||||||
| 432 | # plus any of the above can be prefixed with text| to use | ||||||||||||||||||||||||||||||||||||||
| 433 | # that text as the link text. | ||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||
| 435 | # Additionally, there can also be; | ||||||||||||||||||||||||||||||||||||||
| 436 | # L<scheme:...> | ||||||||||||||||||||||||||||||||||||||
| 437 | # which SHOULD NOT be prepended label| | ||||||||||||||||||||||||||||||||||||||
| 438 | 17 | $seq_argument =~ s/[\r\n]/ /g; | |||||||||||||||||||||||||||||||||||||
| 439 | 17 | my $text = $seq_argument; | |||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||
| 441 | 17 | ▶ | if ( $seq_argument =~ /^([^|]+)\|(.*)$/ ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 442 | { | ||||||||||||||||||||||||||||||||||||||
| 443 | 7 | $text = $1; | |||||||||||||||||||||||||||||||||||||
| 444 | 7 | $seq_argument = $2; | |||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||
| 447 | 17 | ▶ | if ( $seq_argument =~ /^[a-z]+:\//i ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 448 | { | ||||||||||||||||||||||||||||||||||||||
| 449 | 4 | ▶ | $text ||= $seq_argument; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$text ||= $seq_argument
MC/DC0%0/2
$text ||= $seq_argument
$text
$seq_argument
Truth table33%1/3
A ||= B
A= $textB= $seq_argument
| |||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||
| 451 | elsif ( $seq_argument =~ /^(.*?)\/(.*)$/ ) | ||||||||||||||||||||||||||||||||||||||
| 452 | { | ||||||||||||||||||||||||||||||||||||||
| 453 | # name/ident or name/"sect" | ||||||||||||||||||||||||||||||||||||||
| 454 | 8 | my $ident_or_sect = $2; | |||||||||||||||||||||||||||||||||||||
| 455 | 8 | $seq_argument = $1; | |||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||
| 457 | 8 | ▶ | if ( $ident_or_sect =~ /^\"(.*)\"$/ ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 458 | { | ||||||||||||||||||||||||||||||||||||||
| 459 | 4 | my $sect = $1; | |||||||||||||||||||||||||||||||||||||
| 460 | 4 | $sect = substr ( $sect, 0, 30 ); | |||||||||||||||||||||||||||||||||||||
| 461 | 4 | $sect =~ s/\s/_/g; | |||||||||||||||||||||||||||||||||||||
| 462 | 4 | $seq_argument .= '#' . $sect; | |||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||
| 464 | else | ||||||||||||||||||||||||||||||||||||||
| 465 | { | ||||||||||||||||||||||||||||||||||||||
| 466 | 4 | $seq_argument .= '#' . $ident_or_sect; | |||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||
| 469 | elsif ( $seq_argument =~ /^\\?\"(.*)\"$/ ) | ||||||||||||||||||||||||||||||||||||||
| 470 | { | ||||||||||||||||||||||||||||||||||||||
| 471 | 2 | my $sect = $1; | |||||||||||||||||||||||||||||||||||||
| 472 | 2 | $sect = substr ( $sect, 0, 30 ); | |||||||||||||||||||||||||||||||||||||
| 473 | 2 | $sect =~ s/\s/_/g; | |||||||||||||||||||||||||||||||||||||
| 474 | 2 | $seq_argument = '#' . $sect; | |||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||
| 477 | 17 | return "\{tag:link xref='" . $seq_argument . "'\}" . $text . | |||||||||||||||||||||||||||||||||||||
| 478 | "\{\/tag:link\}"; | ||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||
| 480 | elsif ( $seq_command eq 'E' ) | ||||||||||||||||||||||||||||||||||||||
| 481 | { | ||||||||||||||||||||||||||||||||||||||
| 482 | # E<> codes can be numerical! | ||||||||||||||||||||||||||||||||||||||
| 483 | 14 | ▶ | if ( $seq_argument =~ m/^(0[0-7]+|[0-9]+)$/ ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 484 | { | ||||||||||||||||||||||||||||||||||||||
| 485 | # it's octal, convert to decimal! | ||||||||||||||||||||||||||||||||||||||
| 486 | 2 | ▶ | $seq_argument = oct ( $seq_argument ) if $seq_argument =~ m/^0/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||
| 488 | # convert to hex | ||||||||||||||||||||||||||||||||||||||
| 489 | 2 | $seq_argument = sprintf ( '0x%x', $seq_argument ); | |||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||
| 492 | 14 | ▶ | if ( $seq_argument =~ m/^0x([0-9A-Fa-f]{2,4})$/ ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||
| 494 | # E<> is hex! | ||||||||||||||||||||||||||||||||||||||
| 495 | 3 | $seq_argument = "#x" . $1; | |||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||
| 497 | else | ||||||||||||||||||||||||||||||||||||||
| 498 | { | ||||||||||||||||||||||||||||||||||||||
| 499 | # if we know about this code then translate it into hex | ||||||||||||||||||||||||||||||||||||||
| 500 | 11 | ▶ | if ( exists $HTML_Escapes { $seq_argument } ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||||||||
| 502 | 1 | $seq_argument = $HTML_Escapes { $seq_argument }; | |||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||
| 506 | # probably a HTML escape code | ||||||||||||||||||||||||||||||||||||||
| 507 | 14 | $seq_argument = "{tag:escape ref='" . $seq_argument . "'}"; | |||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||
| 509 | 14 | return $seq_argument; | |||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||
| 513 | 5 | 1; | |||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||
| 515 | __END__ | ||||||||||||||||||||||||||||||||||||||