| 1 | package Pod::Tree::HTML; | ||||||||||||||||||||||||||||
| 2 | 30 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # Copyright (c) 1999-2007 by Steven McDougall. This module is free | ||||||||||||||||||||||||||||
| 7 | # software; you can redistribute it and/or modify it under the same | ||||||||||||||||||||||||||||
| 8 | # terms as Perl itself. | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 30 | ▶ | use HTML::Stream; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 30 | ▶ | use IO::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 30 | ▶ | use IO::String; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 30 | ▶ | use Pod::Tree; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 30 | ▶ | use Text::Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 30 | ▶ | use Pod::Tree::BitBucket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 30 | ▶ | use Pod::Tree::StrStream; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 30 | ▶ | use Pod::Tree::HTML::LinkMap; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 30 | ▶ | use constant BGCOLOR => '#ffffff'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 30 | ▶ | use constant TEXT => '#000000'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 30 | our $VERSION = '1.31'; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 124 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 124 | my ( $class, $source, $dest, %options ) = @_; | |||||||||||||||||||||||||||
| 27 | 124 | ▶ | defined $dest or die "Pod::Tree::HTML::new: not enough arguments\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 124 | my $tree = _resolve_source($source); | |||||||||||||||||||||||||||
| 30 | 124 | my ( $fh, $stream ) = _resolve_dest( $dest, $tree, \%options ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 124 | my $options = { | |||||||||||||||||||||||||||
| 33 | bgcolor => BGCOLOR, | ||||||||||||||||||||||||||||
| 34 | depth => 0, | ||||||||||||||||||||||||||||
| 35 | hr => 1, | ||||||||||||||||||||||||||||
| 36 | link_map => Pod::Tree::HTML::LinkMap->new(), | ||||||||||||||||||||||||||||
| 37 | text => TEXT, | ||||||||||||||||||||||||||||
| 38 | toc => 1, | ||||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 124 | my $HTML = { | |||||||||||||||||||||||||||
| 42 | tree => $tree, | ||||||||||||||||||||||||||||
| 43 | root => $tree->get_root, | ||||||||||||||||||||||||||||
| 44 | stream => $stream, | ||||||||||||||||||||||||||||
| 45 | fh => $fh, | ||||||||||||||||||||||||||||
| 46 | text_method => 'text', | ||||||||||||||||||||||||||||
| 47 | options => $options, | ||||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 124 | bless $HTML, $class; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 124 | $HTML->set_options(%options); | |||||||||||||||||||||||||||
| 53 | 124 | $HTML; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 124 | ▶ | sub _resolve_source { | ||||||||||||||||||||||||||
|
Subroutine
_resolve_source: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 57 | 124 | my $source = shift; | |||||||||||||||||||||||||||
| 58 | 124 | my $ref = ref $source; | |||||||||||||||||||||||||||
| 59 | 124 | local *isa = \&UNIVERSAL::isa; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 124 | ▶ | isa( $source, 'Pod::Tree' ) and return $source; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 115 | my $tree = Pod::Tree->new; | |||||||||||||||||||||||||||
| 64 | 115 | ▶ | not $ref and $tree->load_file($source); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 115 | ▶ | isa( $source, 'IO::File' ) and $tree->load_fh($source); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 115 | ▶ | $ref eq 'SCALAR' and $tree->load_string($$source); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 115 | ▶ | $ref eq 'ARRAY' and $tree->load_paragraphs($source); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 115 | ▶ | $tree->loaded | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | or die "Pod::Tree::HTML::_resolve_source: Can't load POD from $source\n"; | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 115 | $tree; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 124 | ▶ | sub _resolve_dest { | ||||||||||||||||||||||||||
|
Subroutine
_resolve_dest: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||
| 76 | 124 | my ( $dest, $tree, $options ) = @_; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | $tree->has_pod | ||||||||||||||||||||||||||||
| 79 | or $options->{empty} | ||||||||||||||||||||||||||||
| 80 | 124 | ▶ | or return ( undef, Pod::Tree::BitBucket->new ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tree->has_pod or $options->{"empty"}
MC/DC100%2/2
$tree->has_pod or $options->{"empty"}
$tree->has_pod
$options->{"empty"}
Truth table100%3/3
A or B
A= $tree->has_podB= $options->{"empty"}
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 118 | local *isa = \&UNIVERSAL::isa; | |||||||||||||||||||||||||||
| 83 | 118 | local *can = \&UNIVERSAL::can; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 118 | ▶ | isa( $dest, 'HTML::Stream' ) and return ( undef, $dest ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 117 | ▶ | isa( $dest, 'IO::File' ) and return ( $dest, HTML::Stream->new($dest) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 110 | ▶ | can( $dest, 'print' ) and return ( $dest, HTML::Stream->new($dest) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 109 | ▶ | if ( ref $dest eq 'SCALAR' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 42 | my $fh = IO::String->new($$dest); | |||||||||||||||||||||||||||
| 91 | 42 | return ( $fh, HTML::Stream->new($fh) ); | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 67 | ▶ | if ( ref $dest eq '' and $dest ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $dest eq "" and $dest
MC/DC0%0/2
ref $dest eq "" and $dest
ref $dest eq ""
$dest
Truth table33%1/3
A and B
A= ref $dest eq ""B= $dest
| |||||||||||||||||||||||||||||
| 95 | 67 | my $fh = IO::File->new; | |||||||||||||||||||||||||||
| 96 | 67 | ▶ | $fh->open( $dest, '>' ) or die "Pod::Tree::HTML::new: Can't open $dest: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 67 | return ( $fh, HTML::Stream->new($fh) ); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | die "Pod::Tree::HTML::_resolve_dest: Can't write HTML to $dest\n"; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 246 | ▶ | sub set_options { | ||||||||||||||||||||||||||
|
Subroutine
set_options: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 246 | my ( $html, %options ) = @_; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 246 | my ( $key, $value ); | |||||||||||||||||||||||||||
| 107 | 246 | ▶ | while ( ( $key, $value ) = each %options ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 339 | $html->{options}{$key} = $value; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub get_options { | ||||||||||||||||||||||||||
|
Subroutine
get_options: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 113 | 0 | my ( $html, @options ) = @_; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | map { $html->{options}{$_} } @options; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub get_stream { shift->{stream} } | ||||||||||||||||||||||||||
|
Subroutine
get_stream: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 122 | ▶ | sub translate { | ||||||||||||||||||||||||||
|
Subroutine
translate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 122 | my ( $html, $template ) = @_; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 122 | ▶ | if ($template) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 36 | $html->_template($template); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||
| 127 | 86 | $html->_translate; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 86 | ▶ | sub _translate { | ||||||||||||||||||||||||||
|
Subroutine
_translate: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 132 | 86 | my $html = shift; | |||||||||||||||||||||||||||
| 133 | 86 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 134 | 86 | my $bgcolor = $html->{options}{bgcolor}; | |||||||||||||||||||||||||||
| 135 | 86 | my $text = $html->{options}{text}; | |||||||||||||||||||||||||||
| 136 | 86 | my $title = $html->_make_title; | |||||||||||||||||||||||||||
| 137 | 86 | my $base = $html->{options}{base}; | |||||||||||||||||||||||||||
| 138 | 86 | my $css = $html->{options}{css}; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 86 | $stream->HTML->HEAD; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 86 | ▶ | defined $title and $stream->TITLE->text($title)->_TITLE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 86 | ▶ | defined $base and $stream->BASE( href => $base ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 86 | ▶ | defined $css and $stream->LINK( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | href => $css, | ||||||||||||||||||||||||||||
| 146 | type => "text/css", | ||||||||||||||||||||||||||||
| 147 | rel => "stylesheet" | ||||||||||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 86 | $stream->_HEAD->BODY( BGCOLOR => $bgcolor, TEXT => $text ); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 86 | $html->emit_toc; | |||||||||||||||||||||||||||
| 153 | 86 | $html->emit_body; | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 86 | $stream->nl->_BODY->_HTML; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 36 | ▶ | sub _template { | ||||||||||||||||||||||||||
|
Subroutine
_template: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 159 | 36 | my ( $html, $tSource ) = @_; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 36 | my $fh = $html->{fh}; | |||||||||||||||||||||||||||
| 162 | 36 | my $sStream = Pod::Tree::StrStream->new; | |||||||||||||||||||||||||||
| 163 | 36 | $html->{stream} = HTML::Stream->new($sStream); | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 36 | our $bgcolor = $html->{options}{bgcolor}; | |||||||||||||||||||||||||||
| 166 | 36 | our $text = $html->{options}{text}; | |||||||||||||||||||||||||||
| 167 | 36 | our $title = $html->_make_title; | |||||||||||||||||||||||||||
| 168 | 36 | our $base = $html->{options}{base}; | |||||||||||||||||||||||||||
| 169 | 36 | our $css = $html->{options}{css}; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 36 | $html->emit_toc; | |||||||||||||||||||||||||||
| 172 | 36 | our $toc = $sStream->get; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 36 | $html->emit_body; | |||||||||||||||||||||||||||
| 175 | 36 | our $body = $sStream->get; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 36 | ▶ | my $template = Text::Template->new( SOURCE => $tSource ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | or die "Can't create Text::Template object: $Text::Template::ERROR\n"; | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 36 | ▶ | $template->fill_in( OUTPUT => $fh ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | or die $Text::Template::ERROR; | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 122 | ▶ | sub _make_title { | ||||||||||||||||||||||||||
|
Subroutine
_make_title: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 185 | 122 | my $html = shift; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 122 | my $title = $html->{options}{title}; | |||||||||||||||||||||||||||
| 188 | 122 | ▶ | defined $title and return $title; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 122 | my $children = $html->{root}->get_children; | |||||||||||||||||||||||||||
| 191 | 122 | my $node1; | |||||||||||||||||||||||||||
| 192 | 122 | my $i = 0; | |||||||||||||||||||||||||||
| 193 | 122 | for my $child (@$children) { | |||||||||||||||||||||||||||
| 194 | 281 | ▶ | $child->is_pod or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 228 | ▶ | $i++ and $node1 = $child; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 228 | ▶ | $node1 and last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 122 | ▶ | $node1 or return undef; ##no critic (ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 114 | my $text = $node1->get_deep_text; | |||||||||||||||||||||||||||
| 202 | 114 | ($title) = split m(\s+-), $text; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 114 | ▶ | $title or return undef; ##no critic (ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 105 | $title =~ s(\s+$)(); | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 105 | $title; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 123 | ▶ | sub emit_toc { | ||||||||||||||||||||||||||
|
Subroutine
emit_toc: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 211 | 123 | my $html = shift; | |||||||||||||||||||||||||||
| 212 | 123 | ▶ | $html->{options}{toc} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 68 | my $root = $html->{root}; | |||||||||||||||||||||||||||
| 215 | 68 | my $nodes = $root->get_children; | |||||||||||||||||||||||||||
| 216 | 68 | my @nodes = @$nodes; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 68 | $html->_emit_toc_1( \@nodes ); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 68 | ▶ | $html->{options}{hr} > 0 and $html->{stream}->HR; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 68 | ▶ | sub _emit_toc_1 { | ||||||||||||||||||||||||||
|
Subroutine
_emit_toc_1: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 224 | 68 | my ( $html, $nodes ) = @_; | |||||||||||||||||||||||||||
| 225 | 68 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 68 | $stream->UL; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 68 | ▶ | while (@$nodes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | 296 | my $node = $nodes->[0]; | |||||||||||||||||||||||||||
| 231 | 296 | ▶ | $node->is_c_head2 and $html->_emit_toc_2($nodes), next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 282 | ▶ | $node->is_c_head1 and $html->_emit_toc_item($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 282 | shift @$nodes; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 68 | $stream->_UL; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 14 | ▶ | sub _emit_toc_2 { | ||||||||||||||||||||||||||
|
Subroutine
_emit_toc_2: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 240 | 14 | my ( $html, $nodes ) = @_; | |||||||||||||||||||||||||||
| 241 | 14 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 14 | $stream->UL; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 14 | ▶ | while (@$nodes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 156 | my $node = $nodes->[0]; | |||||||||||||||||||||||||||
| 247 | 156 | ▶ | $node->is_c_head1 and last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 151 | ▶ | $node->is_c_head2 and $html->_emit_toc_item($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 151 | shift @$nodes; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 14 | $stream->_UL; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 149 | ▶ | sub _emit_toc_item { | ||||||||||||||||||||||||||
|
Subroutine
_emit_toc_item: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 256 | 149 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 257 | 149 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 258 | 149 | my $target = $html->_make_anchor($node); | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 149 | $stream->LI->A( HREF => "#$target" ); | |||||||||||||||||||||||||||
| 261 | 149 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 262 | 149 | $stream->_A; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 123 | ▶ | sub emit_body { | ||||||||||||||||||||||||||
|
Subroutine
emit_body: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 266 | 123 | my $html = shift; | |||||||||||||||||||||||||||
| 267 | 123 | my $root = $html->{root}; | |||||||||||||||||||||||||||
| 268 | 123 | $html->_emit_children($root); | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 2897 | ▶ | sub _emit_children { | ||||||||||||||||||||||||||
|
Subroutine
_emit_children: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 272 | 2897 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 2897 | my $children = $node->get_children; | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 2897 | for my $child (@$children) { | |||||||||||||||||||||||||||
| 277 | 5782 | $html->_emit_node($child); | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 378 | ▶ | sub _emit_siblings { | ||||||||||||||||||||||||||
|
Subroutine
_emit_siblings: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 282 | 378 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 378 | my $siblings = $node->get_siblings; | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 378 | ▶ | if ( @$siblings == 1 and $siblings->[0]{type} eq 'ordinary' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$siblings == 1 and $siblings->[0]{"type"} eq "ordinary"
MC/DC100%2/2
@$siblings == 1 and $siblings->[0]{"type"} eq "ordinary"
@$siblings == 1
$siblings->[0]{"type"} eq "ordinary"
Truth table100%3/3
A and B
A= @$siblings == 1B= $siblings->[0]{"type"} eq "ordinary"
| |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | # don't put <p></p> around a single ordinary paragraph | ||||||||||||||||||||||||||||
| 289 | 315 | $html->_emit_children( $siblings->[0] ); | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | else { | ||||||||||||||||||||||||||||
| 292 | 63 | for my $sibling (@$siblings) { | |||||||||||||||||||||||||||
| 293 | 108 | $html->_emit_node($sibling); | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 5890 | ▶ | sub _emit_node { | ||||||||||||||||||||||||||
|
Subroutine
_emit_node: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 300 | 5890 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 301 | 5890 | my $type = $node->{type}; | |||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 5890 | for ($type) { | |||||||||||||||||||||||||||
| 304 | 5890 | ▶ | /command/ and $html->_emit_command($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 5890 | ▶ | /for/ and $html->_emit_for($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 5890 | ▶ | /item/ and $html->_emit_item($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 5890 | ▶ | /list/ and $html->_emit_list($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 5890 | ▶ | /ordinary/ and $html->_emit_ordinary($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 5890 | ▶ | /sequence/ and $html->_emit_sequence($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | 5890 | ▶ | /text/ and $html->_emit_text($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 5890 | ▶ | /verbatim/ and $html->_emit_verbatim($node); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 30 | my %HeadTag = ( | |||||||||||||||||||||||||||
| 316 | head1 => { 'open' => 'H1', 'close' => '_H1', level => 1 }, | ||||||||||||||||||||||||||||
| 317 | head2 => { 'open' => 'H2', 'close' => '_H2', level => 2 }, | ||||||||||||||||||||||||||||
| 318 | head3 => { 'open' => 'H3', 'close' => '_H3', level => 3 }, | ||||||||||||||||||||||||||||
| 319 | head4 => { 'open' => 'H4', 'close' => '_H4', level => 4 } | ||||||||||||||||||||||||||||
| 320 | ); | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 379 | ▶ | sub _emit_command { | ||||||||||||||||||||||||||
|
Subroutine
_emit_command: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 323 | 379 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 324 | 379 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 325 | 379 | my $command = $node->get_command; | |||||||||||||||||||||||||||
| 326 | 379 | my $head_tag = $HeadTag{$command}; | |||||||||||||||||||||||||||
| 327 | 379 | ▶ | $head_tag or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 328 | 352 | my $anchor = $html->_make_anchor($node); | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 352 | $html->_emit_hr( $head_tag->{level} ); | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 352 | my $tag; | |||||||||||||||||||||||||||
| 333 | 352 | $tag = $head_tag->{'open'}; | |||||||||||||||||||||||||||
| 334 | 352 | $stream->$tag()->A( NAME => $anchor ); | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 352 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 352 | $tag = $head_tag->{'close'}; | |||||||||||||||||||||||||||
| 339 | 352 | $stream->_A->$tag(); | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 352 | ▶ | sub _emit_hr { | ||||||||||||||||||||||||||
|
Subroutine
_emit_hr: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 343 | 352 | my ( $html, $level ) = @_; | |||||||||||||||||||||||||||
| 344 | 352 | ▶ | $html->{options}{hr} > $level or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 345 | 8 | ▶ | $html->{skip_first}++ or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | 6 | $html->{stream}->HR; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 36 | ▶ | sub _emit_for { | ||||||||||||||||||||||||||
|
Subroutine
_emit_for: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 350 | 36 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 36 | my $interpreter = lc $node->get_arg; | |||||||||||||||||||||||||||
| 353 | 36 | my $emit = "_emit_for_$interpreter"; | |||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 36 | ▶ | $html->$emit($node) if $html->can($emit); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 18 | ▶ | sub _emit_for_html { | ||||||||||||||||||||||||||
|
Subroutine
_emit_for_html: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 359 | 18 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 18 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 362 | 18 | $stream->P; | |||||||||||||||||||||||||||
| 363 | 18 | $stream->io->print( $node->get_text ); | |||||||||||||||||||||||||||
| 364 | 18 | $stream->_P; | |||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 9 | ▶ | sub _emit_for_image { | ||||||||||||||||||||||||||
|
Subroutine
_emit_for_image: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 368 | 9 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 9 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 371 | 9 | my $link = $node->get_text; | |||||||||||||||||||||||||||
| 372 | 9 | $link =~ s(\s+$)(); | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 9 | $stream->IMG( src => $link ); | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 378 | ▶ | sub _emit_item { | ||||||||||||||||||||||||||
|
Subroutine
_emit_item: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 378 | 378 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 378 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 381 | 378 | my $item_type = $node->get_item_type; | |||||||||||||||||||||||||||
| 382 | 378 | for ($item_type) { | |||||||||||||||||||||||||||
| 383 | 378 | ▶ | /bullet/ and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 384 | 180 | $stream->LI(); | |||||||||||||||||||||||||||
| 385 | 180 | $html->_emit_siblings($node); | |||||||||||||||||||||||||||
| 386 | 180 | $stream->_LI(); | |||||||||||||||||||||||||||
| 387 | }; | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 378 | ▶ | /number/ and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | 72 | $stream->LI(); | |||||||||||||||||||||||||||
| 391 | 72 | $html->_emit_siblings($node); | |||||||||||||||||||||||||||
| 392 | 72 | $stream->_LI(); | |||||||||||||||||||||||||||
| 393 | }; | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 378 | ▶ | /text/ and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 126 | my $anchor = $html->_make_anchor($node); | |||||||||||||||||||||||||||
| 397 | 126 | $stream->DT->A( NAME => "$anchor" ); | |||||||||||||||||||||||||||
| 398 | 126 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 399 | 126 | $stream->_A->_DT->DD; | |||||||||||||||||||||||||||
| 400 | 126 | $html->_emit_siblings($node); | |||||||||||||||||||||||||||
| 401 | 126 | $stream->_DD; | |||||||||||||||||||||||||||
| 402 | }; | ||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 30 | my %ListTag = ( | |||||||||||||||||||||||||||
| 408 | bullet => { 'open' => 'UL', 'close' => '_UL' }, | ||||||||||||||||||||||||||||
| 409 | number => { 'open' => 'OL', 'close' => '_OL' }, | ||||||||||||||||||||||||||||
| 410 | text => { 'open' => 'DL', 'close' => '_DL' } | ||||||||||||||||||||||||||||
| 411 | ); | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 171 | ▶ | sub _emit_list { | ||||||||||||||||||||||||||
|
Subroutine
_emit_list: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 414 | 171 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 415 | 171 | my ( $list_tag, $tag ); # to quiet -w, see beloew | |||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 171 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 418 | 171 | my $list_type = $node->get_list_type; | |||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 171 | ▶ | $list_type and $list_tag = $ListTag{$list_type}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 421 | 171 | ▶ | $list_tag and $tag = $list_tag->{'open'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 171 | ▶ | $tag and $stream->$tag(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 171 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | 171 | ▶ | $list_tag and $tag = $list_tag->{'close'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | 171 | ▶ | $tag and $stream->$tag(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 716 | ▶ | sub _emit_ordinary { | ||||||||||||||||||||||||||
|
Subroutine
_emit_ordinary: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 431 | 716 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 432 | 716 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 716 | $stream->P; | |||||||||||||||||||||||||||
| 435 | 716 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 436 | 716 | $stream->_P; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 998 | ▶ | sub _emit_sequence { | ||||||||||||||||||||||||||
|
Subroutine
_emit_sequence: called CC=7 SCAR=20.3
| |||||||||||||||||||||||||||||
| 440 | 998 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 998 | for ( $node->get_letter ) { | |||||||||||||||||||||||||||
| 443 | 998 | ▶ | /I|B|C|F/ and $html->_emit_element($node), last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | 574 | ▶ | /S/ and $html->_emit_nbsp($node), last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 445 | 556 | ▶ | /L/ and $html->_emit_link($node), last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | 53 | ▶ | /X/ and $html->_emit_index($node), last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 447 | 0 | ▶ | /E/ and $html->_emit_entity($node), last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 30 | my %ElementTag = ( | |||||||||||||||||||||||||||
| 452 | I => { 'open' => 'I', 'close' => '_I' }, | ||||||||||||||||||||||||||||
| 453 | B => { 'open' => 'B', 'close' => '_B' }, | ||||||||||||||||||||||||||||
| 454 | C => { 'open' => 'CODE', 'close' => '_CODE' }, | ||||||||||||||||||||||||||||
| 455 | F => { 'open' => 'I', 'close' => '_I' } | ||||||||||||||||||||||||||||
| 456 | ); | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 424 | ▶ | sub _emit_element { | ||||||||||||||||||||||||||
|
Subroutine
_emit_element: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 459 | 424 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 424 | my $letter = $node->get_letter; | |||||||||||||||||||||||||||
| 462 | 424 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 424 | my $tag; | |||||||||||||||||||||||||||
| 465 | 424 | $tag = $ElementTag{$letter}{'open'}; | |||||||||||||||||||||||||||
| 466 | 424 | $stream->$tag(); | |||||||||||||||||||||||||||
| 467 | 424 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 468 | 424 | $tag = $ElementTag{$letter}{'close'}; | |||||||||||||||||||||||||||
| 469 | 424 | $stream->$tag(); | |||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | 18 | ▶ | sub _emit_nbsp { | ||||||||||||||||||||||||||
|
Subroutine
_emit_nbsp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 473 | 18 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 18 | my $old_method = $html->{text_method}; | |||||||||||||||||||||||||||
| 476 | 18 | $html->{text_method} = 'text_nbsp'; | |||||||||||||||||||||||||||
| 477 | 18 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 478 | 18 | $html->{text_method} = $old_method; | |||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | 503 | ▶ | sub _emit_link { | ||||||||||||||||||||||||||
|
Subroutine
_emit_link: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 482 | 503 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 503 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 485 | 503 | my $target = $node->get_target; | |||||||||||||||||||||||||||
| 486 | 503 | my $domain = $target->get_domain; | |||||||||||||||||||||||||||
| 487 | 503 | my $method = "make_${domain}_URL"; | |||||||||||||||||||||||||||
| 488 | 503 | my $url = $html->$method($target); | |||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | 503 | $stream->A( HREF => $url ); | |||||||||||||||||||||||||||
| 491 | 503 | $html->_emit_children($node); | |||||||||||||||||||||||||||
| 492 | 503 | $stream->_A; | |||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 481 | ▶ | sub make_POD_URL { | ||||||||||||||||||||||||||
|
Subroutine
make_POD_URL: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 496 | 481 | my ( $html, $target ) = @_; | |||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 481 | my $link_map = $html->{options}{link_map}; | |||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | 481 | ▶ | return $link_map->url( $html, $target ) if $link_map->can("url"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | 25 | $html->make_mapped_URL($target); | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | 25 | ▶ | sub make_mapped_URL { | ||||||||||||||||||||||||||
|
Subroutine
make_mapped_URL: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 506 | 25 | my ( $html, $target ) = @_; | |||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 25 | my $link_map = $html->{options}{link_map}; | |||||||||||||||||||||||||||
| 509 | 25 | ▶ | my $base = $html->{options}{base} || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$html->{'options'}{'base'} || ''
MC/DC0%0/1
$html->{'options'}{'base'} || ''
$html->{'options'}{'base'}
Truth table50%1/2
A
A= $html->{'options'}{'base'}
| |||||||||||||||||||||||||||||
| 510 | 25 | my $page = $target->get_page; | |||||||||||||||||||||||||||
| 511 | 25 | my $section = $target->get_section; | |||||||||||||||||||||||||||
| 512 | 25 | my $depth = $html->{options}{depth}; | |||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | 25 | ( $base, $page, $section ) = $link_map->map( $base, $page, $section, $depth ); | |||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | 25 | $base =~ s(/$)(); | |||||||||||||||||||||||||||
| 517 | 25 | ▶ | $page .= '.html' if $page; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 518 | 25 | my $fragment = $html->escape_2396($section); | |||||||||||||||||||||||||||
| 519 | 25 | my $url = $html->assemble_url( $base, $page, $fragment ); | |||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | 25 | $url; | |||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 22 | ▶ | sub make_HTTP_URL { | ||||||||||||||||||||||||||
|
Subroutine
make_HTTP_URL: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 525 | 22 | my ( $html, $target ) = @_; | |||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 22 | $target->get_page; | |||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 53 | ▶ | sub _emit_index { | ||||||||||||||||||||||||||
|
Subroutine
_emit_index: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 531 | 53 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 53 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 534 | 53 | my $anchor = $html->_make_anchor($node); | |||||||||||||||||||||||||||
| 535 | 53 | $stream->A( NAME => $anchor )->_A; | |||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 0 | ▶ | sub _emit_entity { | ||||||||||||||||||||||||||
|
Subroutine
_emit_entity: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 539 | 0 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 0 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 542 | 0 | my $entity = $node->get_deep_text; | |||||||||||||||||||||||||||
| 543 | 0 | $stream->ent($entity); | |||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 3148 | ▶ | sub _emit_text { | ||||||||||||||||||||||||||
|
Subroutine
_emit_text: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 547 | 3148 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 548 | 3148 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 549 | 3148 | my $text = $node->get_text; | |||||||||||||||||||||||||||
| 550 | 3148 | my $text_method = $html->{text_method}; | |||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | 3148 | $stream->$text_method($text); | |||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | 38 | ▶ | sub _emit_verbatim { | ||||||||||||||||||||||||||
|
Subroutine
_emit_verbatim: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 556 | 38 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 557 | 38 | my $stream = $html->{stream}; | |||||||||||||||||||||||||||
| 558 | 38 | my $text = $node->get_text; | |||||||||||||||||||||||||||
| 559 | 38 | $text =~ s(\n\n$)(); | |||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | 38 | $stream->PRE->text($text)->_PRE; | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | 680 | ▶ | sub _make_anchor { | ||||||||||||||||||||||||||
|
Subroutine
_make_anchor: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 565 | 680 | my ( $html, $node ) = @_; | |||||||||||||||||||||||||||
| 566 | 680 | my $text = $node->get_deep_text; | |||||||||||||||||||||||||||
| 567 | 680 | $text =~ s( \s*\n\s*/ )( )xg; # close line breaks | |||||||||||||||||||||||||||
| 568 | 680 | $text =~ s( ^\s+ | \s+$ )()xg; # clip leading and trailing WS | |||||||||||||||||||||||||||
| 569 | 680 | $html->escape_2396($text); | |||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | 481 | ▶ | sub bin { oct '0b' . join '', @_ } | ||||||||||||||||||||||||||
|
Subroutine
bin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | my @LinkFormat = ( | ||||||||||||||||||||||||||||
| 575 | 2 | ▶ | sub { my ( $b, $p, $f ) = @_; "" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 576 | 152 | ▶ | sub { my ( $b, $p, $f ) = @_; "#$f" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 577 | 122 | ▶ | sub { my ( $b, $p, $f ) = @_; "$p" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 578 | 63 | ▶ | sub { my ( $b, $p, $f ) = @_; "$p#$f" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 579 | 0 | ▶ | sub { my ( $b, $p, $f ) = @_; "$b/" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 580 | 13 | ▶ | sub { my ( $b, $p, $f ) = @_; "#$f" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 581 | 124 | ▶ | sub { my ( $b, $p, $f ) = @_; "$b/$p" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 582 | 5 | ▶ | sub { my ( $b, $p, $f ) = @_; "$b/$p#$f" } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 583 | 30 | ); | |||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | 481 | ▶ | sub assemble_url { | ||||||||||||||||||||||||||
|
Subroutine
assemble_url: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 586 | 481 | my ( $html, $base, $page, $fragment ) = @_; | |||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | 481 | ▶ | my $i = bin map { length($_) ? 1 : 0 } ( $base, $page, $fragment ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 589 | 481 | my $url = $LinkFormat[$i]( $base, $page, $fragment ); | |||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | 481 | $url; | |||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 1161 | ▶ | sub escape_2396 { | ||||||||||||||||||||||||||
|
Subroutine
escape_2396: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 595 | 1161 | my ( $html, $text ) = @_; | |||||||||||||||||||||||||||
| 596 | 1161 | $text =~ s(([^\w\-.!~*'()]))(sprintf("%%%02x", ord($1)))eg; | |||||||||||||||||||||||||||
| 597 | 1161 | $text; | |||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | __END__ | ||||||||||||||||||||||||||||