| 1 | package Perl6::Perldoc::To::Xhtml; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # Everything else is silence... | ||||||||||||||||||||||||||||
| 7 | package UNIVERSAL; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | return q{}; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | package Perl6::Perldoc::Parser::ReturnVal; | ||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | my %DTD_TYPE = ( | |||||||||||||||||||||||||||
| 17 | strict => '-//W3C//DTD XHTML 1.0 Strict//EN', | ||||||||||||||||||||||||||||
| 18 | transitional => '-//W3C//DTD XHTML 1.0 Transitional//EN', | ||||||||||||||||||||||||||||
| 19 | 1 => '-//W3C//DTD XHTML 1.0 Transitional//EN', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _full_doc { | ||||||||||||||||||||||||||
|
Subroutine
_full_doc: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 23 | 0 | my ($tree, $opt_ref, $body) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # Find document title (either explicitly specified or filename)... | ||||||||||||||||||||||||||||
| 26 | 0 | my $title = $opt_ref->{full_doc}{title}; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | if (!defined $title) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $title = $tree->range->{file} || q{}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$tree->range->{'file'} || ''
MC/DC0%0/1
$tree->range->{'file'} || ''
$tree->range->{'file'}
Truth table0%0/2
A
A= $tree->range->{'file'}
| |||||||||||||||||||||||||||||
| 29 | 0 | $title =~ s{.*/}{}xms; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # Extract any embedded CSS specifications | ||||||||||||||||||||||||||||
| 33 | 0 | my $style = $opt_ref->{full_doc}{style}; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (defined $style) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | # Wrap CSS info in <style> tags, if not already so wrapped... | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ($style !~ m{\A \s* <(link|style)\b}ixms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $style = qq{<style type="text/css">\n<!--\n$style\n-->\n</style>\n}; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | else { | ||||||||||||||||||||||||||||
| 41 | 0 | $style = q{}; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # Determine DTD type (either explicitly specified or default)... | ||||||||||||||||||||||||||||
| 45 | 0 | my $requested = $opt_ref->{full_doc}{DTD}; | |||||||||||||||||||||||||||
| 46 | my $type = !defined $requested ? $DTD_TYPE{transitional} | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | : exists $DTD_TYPE{$requested} ? $DTD_TYPE{$requested} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 48 | : $requested | ||||||||||||||||||||||||||||
| 49 | ; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # Encapsulate body in appropriate frou-frou... | ||||||||||||||||||||||||||||
| 52 | 0 | return <<END_STRICT_DOC; | |||||||||||||||||||||||||||
| 53 | <!DOCTYPE html PUBLIC "$type"> | ||||||||||||||||||||||||||||
| 54 | <html> | ||||||||||||||||||||||||||||
| 55 | <head> | ||||||||||||||||||||||||||||
| 56 | <title>$title</title> | ||||||||||||||||||||||||||||
| 57 | $style | ||||||||||||||||||||||||||||
| 58 | </head> | ||||||||||||||||||||||||||||
| 59 | <body> | ||||||||||||||||||||||||||||
| 60 | $body | ||||||||||||||||||||||||||||
| 61 | </body> | ||||||||||||||||||||||||||||
| 62 | </html> | ||||||||||||||||||||||||||||
| 63 | END_STRICT_DOC | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 67 | 0 | my ($self, $opt_ref) = @_; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $opt_ref ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opt_ref ||= {}
MC/DC0%0/1
$opt_ref ||= {}
$opt_ref
Truth table0%0/2
A
A= $opt_ref
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | croak "'text_to_entities' option must be subroutine reference" | ||||||||||||||||||||||||||||
| 72 | if exists $opt_ref->{text_to_entities} | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | && ref($opt_ref->{text_to_entities}) ne 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $opt_ref->{"text_to_entities"} and ref $opt_ref->{"text_to_entities"} ne "CODE"
MC/DC0%0/2
exists $opt_ref->{"text_to_entities"} and ref $opt_ref->{"text_to_entities"} ne "CODE"
exists $opt_ref->{"text_to_entities"}
ref $opt_ref->{"text_to_entities"} ne "CODE"
Truth table0%0/3
A and B
A= exists $opt_ref->{"text_to_entities"}B= ref $opt_ref->{"text_to_entities"} ne "CODE"
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my $xhtml_rep = $self->{tree}->to_xhtml($opt_ref); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($opt_ref->{notes}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $xhtml_rep .= $opt_ref->{notes_prefix} || "<h1>Notes</h1>\n"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opt_ref->{'notes_prefix'} || "<h1>Notes</h1>\n"
MC/DC0%0/1
$opt_ref->{'notes_prefix'} || "<h1>Notes</h1>\n"
$opt_ref->{'notes_prefix'}
Truth table0%0/2
A
A= $opt_ref->{'notes_prefix'}
| |||||||||||||||||||||||||||||
| 79 | 0 | $xhtml_rep .= $opt_ref->{notes}; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (exists $opt_ref->{full_doc}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | $xhtml_rep = _full_doc($self->{tree}, $opt_ref, $xhtml_rep); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | return $xhtml_rep; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | package Perl6::Perldoc::Root; | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub add_xhtml_nesting { | ||||||||||||||||||||||||||
|
Subroutine
add_xhtml_nesting: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 92 | 0 | my ($self, $xhtml, $default) = @_; | |||||||||||||||||||||||||||
| 93 | 0 | my $nested = $self->option('nested'); | |||||||||||||||||||||||||||
| 94 | 0 | ▶ | if (!defined $nested) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $nested = $default || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$default || 0
MC/DC0%0/1
$default || 0
$default
Truth table0%0/2
A
A= $default
| |||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 0 | for (1..$nested) { | |||||||||||||||||||||||||||
| 98 | 0 | $xhtml = "<blockquote>$xhtml</blockquote>"; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 0 | return $xhtml; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub _list_to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
_list_to_xhtml: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 104 | 0 | my $parent = shift; | |||||||||||||||||||||||||||
| 105 | 0 | my $list_ref = shift; | |||||||||||||||||||||||||||
| 106 | 0 | my ($opt_ref) = @_; | |||||||||||||||||||||||||||
| 107 | 0 | my $xhtml = q{}; | |||||||||||||||||||||||||||
| 108 | 0 | for my $content ( @{$list_ref} ) { | |||||||||||||||||||||||||||
| 109 | 0 | ▶ | next if ! defined $content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (ref $content) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | $xhtml .= $content->to_xhtml(@_); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | else { | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if (exists $opt_ref->{text_to_entities}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | $content = $opt_ref->{text_to_entities}->($parent, $content); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | else { | ||||||||||||||||||||||||||||
| 118 | 0 | $content =~ s{&}{&}gxms; | |||||||||||||||||||||||||||
| 119 | 0 | $content =~ s{<}{<}gxms; | |||||||||||||||||||||||||||
| 120 | 0 | $content =~ s{>}{>}gxms; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | 0 | $xhtml .= $content; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | 0 | return $xhtml; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | 0 | my $content = $self->_list_to_xhtml([$self->content],@_); | |||||||||||||||||||||||||||
| 131 | 0 | my $name = $self->_list_to_xhtml([ | |||||||||||||||||||||||||||
| 132 | Perl6::Perldoc::FormattingCode::L::_flatten([$self->content]) | ||||||||||||||||||||||||||||
| 133 | ]); | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # Assign jump targets to headings, semantic blocks, and user-defined... | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my $is_target | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->isa('Perl6::Perldoc::Block') && $self->typename =~ /\A head\d+ \z | [[:upper:]] /msx
MC/DC0%0/2
$self->isa('Perl6::Perldoc::Block') && $self->typename =~ /\A head\d+ \z | [[:upper:]] /msx
$self->isa('Perl6::Perldoc::Block')
$self->typename =~ /\A head\d+ \z | [[:upper:]] /msx
Truth table0%0/3
A && B
A= $self->isa('Perl6::Perldoc::Block')B= $self->typename =~ /\A head\d+ \z | [[:upper:]] /msx
| |||||||||||||||||||||||||||||
| 137 | = $self->isa('Perl6::Perldoc::Block') | ||||||||||||||||||||||||||||
| 138 | && $self->typename =~ m{\A head\d+ \z | [[:upper:]] }xms; | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($is_target) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | $content = qq{<a name="$name"><a name="} | |||||||||||||||||||||||||||
| 142 | . $self->id() | ||||||||||||||||||||||||||||
| 143 | . qq{">$content</a></a>}; | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | return $self->add_xhtml_nesting($content); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | # Representation of file itself... | ||||||||||||||||||||||||||||
| 150 | package Perl6::Perldoc::Document; | ||||||||||||||||||||||||||||
| 151 | 1 | ▶ | use base 'Perl6::Perldoc::Root'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | # Ambient text around the Pod... | ||||||||||||||||||||||||||||
| 154 | package Perl6::Perldoc::Ambient; | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 157 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 158 | 0 | return q{}; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | # Pod blocks... | ||||||||||||||||||||||||||||
| 162 | package Perl6::Perldoc::Block; | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | # Standard =pod block... | ||||||||||||||||||||||||||||
| 165 | package Perl6::Perldoc::Block::pod; | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # Standard =para block (may be implicit)... | ||||||||||||||||||||||||||||
| 168 | package Perl6::Perldoc::Block::para; | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 171 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 172 | 0 | return '<p>' . $self->SUPER::to_xhtml(@_) . "</p>\n"; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | # Standard =code block (may be implicit)... | ||||||||||||||||||||||||||||
| 176 | package Perl6::Perldoc::Block::code; | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub _min { | ||||||||||||||||||||||||||
|
Subroutine
_min: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 179 | 0 | my $min = shift; | |||||||||||||||||||||||||||
| 180 | 0 | for my $next (@_) { | |||||||||||||||||||||||||||
| 181 | 0 | ▶ | $min = $next if $next < $min; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 0 | return $min; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 187 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 188 | 0 | my $xhtml = $self->_list_to_xhtml([$self->content], @_); | |||||||||||||||||||||||||||
| 189 | 0 | my $left_space = _min(map { length } $xhtml =~ m{^ [^\S\n]* (?= \S) }gxms); | |||||||||||||||||||||||||||
| 190 | 0 | $xhtml =~ s{^ [^\S\n]{$left_space} }{}gxms; | |||||||||||||||||||||||||||
| 191 | 0 | $xhtml = '<pre>' . $xhtml . '</pre>'; | |||||||||||||||||||||||||||
| 192 | 0 | return $self->add_xhtml_nesting($xhtml, 1); | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | # Standard =input block | ||||||||||||||||||||||||||||
| 197 | package Perl6::Perldoc::Block::input; | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | 0 | return '<blockquote><pre><kbd>' | |||||||||||||||||||||||||||
| 202 | . $self->_list_to_xhtml([$self->content], @_) | ||||||||||||||||||||||||||||
| 203 | . "</kbd></pre></blockquote>\n"; | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | # Standard =output block | ||||||||||||||||||||||||||||
| 208 | package Perl6::Perldoc::Block::output; | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 211 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 212 | 0 | return '<blockquote><pre><samp>' | |||||||||||||||||||||||||||
| 213 | . $self->_list_to_xhtml([$self->content], @_) | ||||||||||||||||||||||||||||
| 214 | . "</samp></pre></blockquote>\n"; | ||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | # Standard =config block... | ||||||||||||||||||||||||||||
| 218 | package Perl6::Perldoc::Config; | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 222 | 0 | return q{}; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | # Standard =table block... | ||||||||||||||||||||||||||||
| 226 | package Perl6::Perldoc::Block::table; | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 229 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | my $caption = $self->option('caption') || q{}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->option('caption') || ''
MC/DC0%0/1
$self->option('caption') || ''
$self->option('caption')
Truth table0%0/2
A
A= $self->option('caption')
| |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ($caption) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if (ref($caption) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | $caption = "@{$caption}"; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | 0 | $caption = $self->_list_to_xhtml([$caption]); | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | my $xhtml = qq{<a name="$caption"><a name="} . $self->id() . qq{"><table>\n}; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($caption) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 0 | $xhtml .= qq{<caption>$caption</caption>\n}; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | for my $row ( $self->rows() ) { | |||||||||||||||||||||||||||
| 246 | 0 | $xhtml .= "<tr>\n"; | |||||||||||||||||||||||||||
| 247 | 0 | for my $cell ( $row->cells() ) { | |||||||||||||||||||||||||||
| 248 | 0 | ▶ | $xhtml .= $cell->is_header ? "<th>\n" : "<td>\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 0 | for my $block ( $cell->content ) { | |||||||||||||||||||||||||||
| 250 | 0 | $xhtml .= $block->to_xhtml(@_); | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $xhtml .= $cell->is_header ? "</th>\n" : "</td>\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 0 | $xhtml .= "</tr>\n"; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 0 | $xhtml .= "</table></a></a>\n"; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | return $self->add_xhtml_nesting($xhtml); | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | package Perl6::Perldoc::Block::table::Row; | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | package Perl6::Perldoc::Block::table::Cell; | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | # Standard =head1 block... | ||||||||||||||||||||||||||||
| 266 | package Perl6::Perldoc::Block::head1; | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 269 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 270 | 0 | my $title = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 271 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||||||||||
| 272 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||||||||||
| 273 | 0 | my $number = $self->number; | |||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | $title = "$number. $title"; | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | 0 | return qq{<h1>$title</h1>\n}; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | # Standard =head2 block... | ||||||||||||||||||||||||||||
| 281 | package Perl6::Perldoc::Block::head2; | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 285 | 0 | my $title = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 286 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||||||||||
| 287 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||||||||||
| 288 | 0 | my $number = $self->number; | |||||||||||||||||||||||||||
| 289 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 0 | $title = "$number. $title"; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | 0 | return qq{<h2>$title</h2>\n}; | |||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | # Standard =head3 block... | ||||||||||||||||||||||||||||
| 296 | package Perl6::Perldoc::Block::head3; | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 299 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 300 | 0 | my $title = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 301 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||||||||||
| 302 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||||||||||
| 303 | 0 | my $number = $self->number; | |||||||||||||||||||||||||||
| 304 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 0 | $title = "$number. $title"; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | 0 | return qq{<h3>$title</h3>\n}; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | # Standard =head4 block... | ||||||||||||||||||||||||||||
| 311 | package Perl6::Perldoc::Block::head4; | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 314 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 315 | 0 | my $title = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 316 | 0 | $title =~ s{\A\s+|\s+\Z}{}gxms; | |||||||||||||||||||||||||||
| 317 | 0 | $title =~ s{\s+}{ }gxms; | |||||||||||||||||||||||||||
| 318 | 0 | my $number = $self->number; | |||||||||||||||||||||||||||
| 319 | 0 | ▶ | if (defined $number) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | 0 | $title = "$number. $title"; | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | 0 | return qq{<h4>$title</h4>\n}; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | # Implicit list block... | ||||||||||||||||||||||||||||
| 326 | package Perl6::Perldoc::Block::list; | ||||||||||||||||||||||||||||
| 327 | 1 | ▶ | use base 'Perl6::Perldoc::Root'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 330 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 331 | 0 | my $xhtml = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 332 | 0 | my ($first_item) = $self->content; | |||||||||||||||||||||||||||
| 333 | 0 | ▶ | if ($first_item->option('term')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 334 | 0 | return '<dl>' . $xhtml . '</dl>'; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | elsif ($first_item->number) { | ||||||||||||||||||||||||||||
| 337 | 0 | return '<ol>' . $xhtml . '</ol>'; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | else { | ||||||||||||||||||||||||||||
| 340 | 0 | return '<ul>' . $xhtml . '</ul>'; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | # Standard =item block... | ||||||||||||||||||||||||||||
| 346 | package Perl6::Perldoc::Block::item; | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 349 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 0 | ▶ | my $counter = $self->number || q{}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->number || ''
MC/DC0%0/1
$self->number || ''
$self->number
Truth table0%0/2
A
A= $self->number
| |||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if (my $term = $self->term()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | open my $term_fh, '<', \$term | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | or die "Internal error: Can't parse :term contents"; | ||||||||||||||||||||||||||||
| 356 | 0 | $term = $self->term( {as_objects=>1} )->to_xhtml(@_); | |||||||||||||||||||||||||||
| 357 | 0 | ▶ | if (length $counter) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | $term =~ s{\A (\s* <[^>]+>)}{$1$counter. }xms; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | 0 | return "<dt>$term</dt><dd>" | |||||||||||||||||||||||||||
| 361 | . $self->SUPER::to_xhtml(@_) | ||||||||||||||||||||||||||||
| 362 | . "</dd>\n"; | ||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||
| 365 | 0 | $counter =~ s{.*[.]?(\d+)$}{ value="$1"}xms; | |||||||||||||||||||||||||||
| 366 | 0 | return "<li$counter>" | |||||||||||||||||||||||||||
| 367 | . $self->SUPER::to_xhtml(@_) | ||||||||||||||||||||||||||||
| 368 | . "</li>\n"; | ||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | # Implicit toclist block... | ||||||||||||||||||||||||||||
| 373 | package Perl6::Perldoc::Block::toclist; | ||||||||||||||||||||||||||||
| 374 | 1 | ▶ | use base 'Perl6::Perldoc::Root'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 377 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | # Convert list items to XHTML, and return in an XHTML list... | ||||||||||||||||||||||||||||
| 380 | 0 | my $xhtml = join q{}, map {$_->to_xhtml(@_)} $self->content; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | return '<ul class="toclist">' . $xhtml . '</ul>'; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | # Standard =tocitem block... | ||||||||||||||||||||||||||||
| 387 | package Perl6::Perldoc::Block::tocitem; | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 390 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 0 | my $target = $self->target(); | |||||||||||||||||||||||||||
| 393 | 0 | my $typename = $self->typename(); | |||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | my @title = $self->title; | |||||||||||||||||||||||||||
| 396 | 0 | ▶ | return "" if ! @title; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 0 | my $title = $self->_list_to_xhtml(\@title, @_); | |||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | return qq{<a href="$target">\n<li class="$typename">$title</li></a>\n}; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | # Handle headN's and itemN's and tocitemN's... | ||||||||||||||||||||||||||||
| 404 | 1 | for my $depth (1..100) { | |||||||||||||||||||||||||||
| 405 | 1 | ▶ | no strict qw< refs >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 100 | @{'Perl6::Perldoc::Block::item'.$depth.'::ISA'} | |||||||||||||||||||||||||||
| 408 | = 'Perl6::Perldoc::Block::item'; | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 100 | @{'Perl6::Perldoc::Block::tocitem'.$depth.'::ISA'} | |||||||||||||||||||||||||||
| 411 | = 'Perl6::Perldoc::Block::tocitem'; | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 100 | ▶ | next if $depth < 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 414 | 96 | @{'Perl6::Perldoc::Block::head'.$depth.'::ISA'} | |||||||||||||||||||||||||||
| 415 | = 'Perl6::Perldoc::Block::head4'; | ||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | # Standard =nested block... | ||||||||||||||||||||||||||||
| 419 | package Perl6::Perldoc::Block::nested; | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 422 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 423 | 0 | return '<blockquote>' . $self->SUPER::to_xhtml(@_) . "</blockquote>\n"; | |||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | # Standard =comment block... | ||||||||||||||||||||||||||||
| 427 | package Perl6::Perldoc::Block::comment; | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 430 | 0 | return q{}; | |||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | # Standard SEMANTIC blocks... | ||||||||||||||||||||||||||||
| 434 | package Perl6::Perldoc::Block::Semantic; | ||||||||||||||||||||||||||||
| 435 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||
| 436 | 1 | my @semantic_blocks = qw( | |||||||||||||||||||||||||||
| 437 | NAME NAMES | ||||||||||||||||||||||||||||
| 438 | VERSION VERSIONS | ||||||||||||||||||||||||||||
| 439 | SYNOPSIS SYNOPSES | ||||||||||||||||||||||||||||
| 440 | DESCRIPTION DESCRIPTIONS | ||||||||||||||||||||||||||||
| 441 | USAGE USAGES | ||||||||||||||||||||||||||||
| 442 | INTERFACE INTERFACES | ||||||||||||||||||||||||||||
| 443 | METHOD METHODS | ||||||||||||||||||||||||||||
| 444 | SUBROUTINE SUBROUTINES | ||||||||||||||||||||||||||||
| 445 | OPTION OPTIONS | ||||||||||||||||||||||||||||
| 446 | DIAGNOSTIC DIAGNOSTICS | ||||||||||||||||||||||||||||
| 447 | ERROR ERRORS | ||||||||||||||||||||||||||||
| 448 | WARNING WARNINGS | ||||||||||||||||||||||||||||
| 449 | DEPENDENCY DEPENDENCIES | ||||||||||||||||||||||||||||
| 450 | BUG BUGS | ||||||||||||||||||||||||||||
| 451 | SEEALSO SEEALSOS | ||||||||||||||||||||||||||||
| 452 | ACKNOWLEDGEMENT ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 453 | AUTHOR AUTHORS | ||||||||||||||||||||||||||||
| 454 | COPYRIGHT COPYRIGHTS | ||||||||||||||||||||||||||||
| 455 | DISCLAIMER DISCLAIMERS | ||||||||||||||||||||||||||||
| 456 | LICENCE LICENCES | ||||||||||||||||||||||||||||
| 457 | LICENSE LICENSES | ||||||||||||||||||||||||||||
| 458 | TITLE TITLES | ||||||||||||||||||||||||||||
| 459 | FOREWORD FOREWORDS | ||||||||||||||||||||||||||||
| 460 | SUMMARY SUMMARIES | ||||||||||||||||||||||||||||
| 461 | SECTION SECTIONS | ||||||||||||||||||||||||||||
| 462 | CHAPTER CHAPTERS | ||||||||||||||||||||||||||||
| 463 | APPENDIX APPENDIXES APPENDICES | ||||||||||||||||||||||||||||
| 464 | TOC TOCS | ||||||||||||||||||||||||||||
| 465 | INDEX INDEXES INDICES | ||||||||||||||||||||||||||||
| 466 | ); | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | # Reuse content-to-xhtml converter | ||||||||||||||||||||||||||||
| 469 | # *_list_to_xhtml = *Perl6::Perldoc::Root::_list_to_xhtml; | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | # All semantic blocks are self-titling, followed by contents... | ||||||||||||||||||||||||||||
| 472 | 1 | for my $blockname (@semantic_blocks) { | |||||||||||||||||||||||||||
| 473 | 1 | ▶ | no strict qw< refs >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 60 | *{ "Perl6::Perldoc::Block::${blockname}::to_xhtml" } | |||||||||||||||||||||||||||
| 476 | 0 | ▶ | = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 477 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | 0 | my @title = $self->title(); | |||||||||||||||||||||||||||
| 480 | 0 | ▶ | return "" if !@title; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | 0 | my $title = $self->_list_to_xhtml(\@title, @_); | |||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | return qq{<a name="$title"><a name="} | |||||||||||||||||||||||||||
| 485 | . $self->id() | ||||||||||||||||||||||||||||
| 486 | . qq{"><h1 class="$blockname">$title</h1></a></a>\n} | ||||||||||||||||||||||||||||
| 487 | . $self->_list_to_xhtml([$self->content], @_); | ||||||||||||||||||||||||||||
| 488 | 60 | }; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | # Base class for formatting codes... | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | package Perl6::Perldoc::FormattingCode; | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | package Perl6::Perldoc::FormattingCode::Named; | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | # Basis formatter... | ||||||||||||||||||||||||||||
| 500 | package Perl6::Perldoc::FormattingCode::B; | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 503 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 504 | 0 | return '<strong>' . $self->SUPER::to_xhtml(@_) . "</strong>"; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | # Code formatter... | ||||||||||||||||||||||||||||
| 508 | package Perl6::Perldoc::FormattingCode::C; | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 511 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 512 | 0 | return '<code>' . $self->SUPER::to_xhtml(@_) . "</code>"; | |||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | # Definition formatter... | ||||||||||||||||||||||||||||
| 516 | package Perl6::Perldoc::FormattingCode::D; | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 519 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 520 | 0 | my $tag = join q{}, $self->content; | |||||||||||||||||||||||||||
| 521 | 0 | $tag = $self->_list_to_xhtml([$tag]); | |||||||||||||||||||||||||||
| 522 | 0 | return qq{<a name="$tag"><dfn>} . $self->SUPER::to_xhtml(@_) . '</dfn></a>'; | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | # Entity formatter... | ||||||||||||||||||||||||||||
| 527 | package Perl6::Perldoc::FormattingCode::E; | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 1 | my %is_break_entity = ( | |||||||||||||||||||||||||||
| 530 | 'LINE FEED (LF)' => 1, LF => 1, | ||||||||||||||||||||||||||||
| 531 | 'CARRIAGE RETURN (CR)' => 1, CR => 1, | ||||||||||||||||||||||||||||
| 532 | 'NEXT LINE (NEL)' => 1, NEL => 1, | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | 'FORM FEED (FF)' => 10, FF => 10, | ||||||||||||||||||||||||||||
| 535 | ); | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | # Convert E<> contents to XHTML named or numeric entity... | ||||||||||||||||||||||||||||
| 538 | 0 | ▶ | sub _to_xhtml_entity { | ||||||||||||||||||||||||||
|
Subroutine
_to_xhtml_entity: not called CC=5 SCAR=30.5
| |||||||||||||||||||||||||||||
| 539 | 0 | my ($spec) = @_; | |||||||||||||||||||||||||||
| 540 | # Is it a line break? | ||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if (my $BR_count = $is_break_entity{$spec}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 542 | 0 | return '<br/>' x $BR_count; | |||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||
| 544 | # Is it a named specification? | ||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if ($spec !~ m{\A \d}xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 546 | # Try Unicode first... | ||||||||||||||||||||||||||||
| 547 | 1 | ▶ | use charnames ':full'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 548 | 0 | my $ord = charnames::vianame($spec); | |||||||||||||||||||||||||||
| 549 | 0 | ▶ | return sprintf('&#%d;',$ord) if defined $ord; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | # Otherwise, it must be an XHMTL named entity... | ||||||||||||||||||||||||||||
| 552 | 0 | return qq{&$spec;}; | |||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | # Otherwise, it's the numeric codepoint in some base... | ||||||||||||||||||||||||||||
| 555 | else { | ||||||||||||||||||||||||||||
| 556 | # Convert Perl 6 octals and decimals to Perl 5 notation... | ||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if ($spec !~ s{\A 0o}{0}xms) { # Convert octal | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 558 | 0 | $spec =~ s{\A 0d}{}xms; # Convert explicit decimal | |||||||||||||||||||||||||||
| 559 | 0 | $spec =~ s{\A 0+ (?=\d)}{}xms; # Convert implicit decimal | |||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | # Then return the XHTML numeric code... | ||||||||||||||||||||||||||||
| 563 | 0 | return sprintf '&#%d;', eval $spec; | |||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 568 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 569 | return join q{}, | ||||||||||||||||||||||||||||
| 570 | 0 | map {_to_xhtml_entity($_)} | |||||||||||||||||||||||||||
| 571 | split /\s*;\s*/, scalar $self->content; | ||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | # Important formatter... | ||||||||||||||||||||||||||||
| 575 | package Perl6::Perldoc::FormattingCode::I; | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 578 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 579 | 0 | return '<em>' . $self->SUPER::to_xhtml(@_) . "</em>"; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | # Keyboard input formatter... | ||||||||||||||||||||||||||||
| 583 | package Perl6::Perldoc::FormattingCode::K; | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 586 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 587 | 0 | return '<kbd>' . $self->SUPER::to_xhtml(@_) . "</kbd>"; | |||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | # Link formatter... | ||||||||||||||||||||||||||||
| 591 | package Perl6::Perldoc::FormattingCode::L; | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | 1 | my $PERLDOC_ORG = 'http://perldoc.perl.org/'; | |||||||||||||||||||||||||||
| 594 | 1 | my $SEARCH = 'http://www.google.com/search?q='; | |||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 597 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 598 | 0 | ▶ | my $target = $self->target() || '????'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->target || '????'
MC/DC0%0/1
$self->target || '????'
$self->target
Truth table0%0/2
A
A= $self->target
| |||||||||||||||||||||||||||||
| 599 | 0 | my $local_target = substr($target,0,1) eq '#'; | |||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | 0 | ▶ | my $url = $target =~ m{\A doc: ([^#] .*)}xms ? "$PERLDOC_ORG$1.html" | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 602 | : $target =~ m{\A (?:doc:)? ( [#] .*)}xms ? $1 | ||||||||||||||||||||||||||||
| 603 | : $target =~ m{\A defn: ( .*)}xms ? "#$1" | ||||||||||||||||||||||||||||
| 604 | : $target =~ m{\A man: ( .*)}xms ? "help:$1" | ||||||||||||||||||||||||||||
| 605 | : $target =~ m{\A (is.n): ( .*)}xms ? "$SEARCH$1+$2" | ||||||||||||||||||||||||||||
| 606 | : $target | ||||||||||||||||||||||||||||
| 607 | ; | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | 0 | $url =~ s{\s+}{ }gxms; | |||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | 0 | my $xhtml = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 612 | 0 | ▶ | if ($local_target) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 613 | 0 | $xhtml =~ s{\A [#]}{}xms; | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | else { | ||||||||||||||||||||||||||||
| 616 | 0 | $xhtml =~ s{\A (?: doc | defn | file | man ) : }{}xms; | |||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||
| 618 | 0 | return qq{<a href="$url">$xhtml</a>}; | |||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | # Meta-formatter... | ||||||||||||||||||||||||||||
| 622 | package Perl6::Perldoc::FormattingCode::M; | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | # Note formatter... | ||||||||||||||||||||||||||||
| 626 | package Perl6::Perldoc::FormattingCode::N; | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 629 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 630 | 0 | my $count = ++$_[0]{note_count}; | |||||||||||||||||||||||||||
| 631 | 0 | my $marker = "<sup>$count</sup>"; | |||||||||||||||||||||||||||
| 632 | $_[0]{notes} | ||||||||||||||||||||||||||||
| 633 | 0 | .= qq{<p><a name="_nb_out_$count" href="#_nb_in_$count">$marker</a>} | |||||||||||||||||||||||||||
| 634 | . $self->SUPER::to_xhtml(@_) | ||||||||||||||||||||||||||||
| 635 | . "</p>\n"; | ||||||||||||||||||||||||||||
| 636 | 0 | return qq{<a name="_nb_in_$count" href="#_nb_out_$count">$marker</a>}; | |||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | # Placement link formatter... | ||||||||||||||||||||||||||||
| 640 | package Perl6::Perldoc::FormattingCode::P; | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | # Read a file | ||||||||||||||||||||||||||||
| 643 | 0 | ▶ | sub _slurp { | ||||||||||||||||||||||||||
|
Subroutine
_slurp: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 644 | 0 | my ($base, $file) = @_; | |||||||||||||||||||||||||||
| 645 | 0 | my ($handle, $contents); | |||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | 0 | ▶ | if (defined $base and not $file =~ m{\A /}x) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $base and not $file =~ m[\A /]x
MC/DC0%0/2
defined $base and not $file =~ m[\A /]x
defined $base
not $file =~ m[\A /]x
Truth table0%0/3
A and not(B)
A= defined $baseB= not $file =~ m[\A /]x
| |||||||||||||||||||||||||||||
| 648 | 0 | $base =~ s{ [^/]+ \Z}{}x; | |||||||||||||||||||||||||||
| 649 | 0 | $file = $base . $file; | |||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if (open $handle, '<', $file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 652 | 0 | local $/; | |||||||||||||||||||||||||||
| 653 | 0 | $contents = <$handle>; | |||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||
| 655 | 0 | return $contents; | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 659 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 660 | 0 | my $link = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | # Table-of-contents placement... | ||||||||||||||||||||||||||||
| 663 | 0 | ▶ | if ($self->target =~ m{\A \s* toc :}xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 664 | 0 | return $link; | |||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | # Handle inlined Pod... | ||||||||||||||||||||||||||||
| 668 | 0 | ▶ | if ($self->target =~ m{\A \s* file : (.+\.pod) \s* \Z}ixms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 669 | 0 | my $contents = _slurp($self->range->{file}, $1); | |||||||||||||||||||||||||||
| 670 | 0 | ▶ | return Perl6::Perldoc::Parser | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 671 | ->parse(\$contents, { all_pod => 1 }) | ||||||||||||||||||||||||||||
| 672 | ->report_errors()->to_xhtml() if defined $contents; | ||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | # Handle inlined HTML... | ||||||||||||||||||||||||||||
| 676 | 0 | ▶ | if ($self->target =~ m{\A \s* file : (.+\.html?) \s* \Z}ixms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 677 | 0 | my $contents = _slurp($self->range->{file}, $1); | |||||||||||||||||||||||||||
| 678 | 0 | ▶ | return $contents if defined $contents; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | # If above attempts fail, format as an outwards link... | ||||||||||||||||||||||||||||
| 682 | 0 | return qq{See: <a href="$link">$link</a>}; | |||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | # Replacable item formatter... | ||||||||||||||||||||||||||||
| 686 | package Perl6::Perldoc::FormattingCode::R; | ||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 689 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 690 | 0 | return '<var>' . $self->SUPER::to_xhtml(@_) . "</var>"; | |||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | # Space-preserving formatter... | ||||||||||||||||||||||||||||
| 694 | package Perl6::Perldoc::FormattingCode::S; | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 697 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 698 | 0 | my $text = $self->SUPER::to_xhtml(@_); | |||||||||||||||||||||||||||
| 699 | 0 | $text =~ s{[ ]}{ }gxms; | |||||||||||||||||||||||||||
| 700 | 0 | $text =~ s{\n}{<br/>}gxms; | |||||||||||||||||||||||||||
| 701 | 0 | return $text; | |||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | # Terminal output formatter... | ||||||||||||||||||||||||||||
| 706 | package Perl6::Perldoc::FormattingCode::T; | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 709 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 710 | 0 | return '<samp>' . $self->SUPER::to_xhtml(@_) . "</samp>"; | |||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | # Unusual formatter... | ||||||||||||||||||||||||||||
| 714 | package Perl6::Perldoc::FormattingCode::U; | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 717 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 718 | 0 | return '<em>' . $self->SUPER::to_xhtml(@_) . "</em>"; | |||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | # Verbatim formatter... | ||||||||||||||||||||||||||||
| 722 | package Perl6::Perldoc::FormattingCode::V; | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | # indeX formatter... | ||||||||||||||||||||||||||||
| 725 | package Perl6::Perldoc::FormattingCode::X; | ||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||
| 727 | # Zero-width formatter... | ||||||||||||||||||||||||||||
| 728 | package Perl6::Perldoc::FormattingCode::Z; | ||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | 0 | ▶ | sub to_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
to_xhtml: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 731 | 0 | return q{}; | |||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | # Standard =table block... | ||||||||||||||||||||||||||||
| 736 | package Perl6::Perldoc::Block::table; | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | 1 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||
| 740 | __END__ | ||||||||||||||||||||||||||||