| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package ChordPro::Output::HTML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Produce nice viewable HMTL output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # You should be able to print it using a decent browser (notexisting) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # or a formatting tool like weasyprint. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use ChordPro::Files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use ChordPro::Paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use ChordPro::Output::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use ChordPro::Utils qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use ChordPro::Assets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Storable 'dclone'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | sub generate_songbook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_songbook: called CC=17 SCAR=32.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | my ( $self, $sb ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | my @book; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | my $cfg = $::config->{html} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$main::config->{"html"} // {}
MC/DC0%0/1
$main::config->{"html"} // {}
$main::config->{"html"}
Truth table50%1/2
A
A= $main::config->{"html"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | $cfg->{styles}->{default} //= "chordpro.css"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{"styles"}{"default"} //= "chordpro.css"
MC/DC0%0/1
$cfg->{"styles"}{"default"} //= "chordpro.css"
$cfg->{"styles"}{"default"}
Truth table50%1/2
A
A= $cfg->{"styles"}{"default"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | $cfg->{styles}->{screen} //= $cfg->{styles}->{display} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$cfg->{"styles"}{"screen"} //= $cfg->{"styles"}{"display"} // ""
$cfg->{"styles"}{"display"} // ""
MC/DC0%0/1
$cfg->{"styles"}{"screen"} //= $cfg->{"styles"}{"display"} // ""
$cfg->{"styles"}{"screen"}
Truth table50%1/2
A
A= $cfg->{"styles"}{"screen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | $cfg->{styles}->{print} //= "chordpro_print.css"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{"styles"}{"print"} //= "chordpro_print.css"
MC/DC0%0/1
$cfg->{"styles"}{"print"} //= "chordpro_print.css"
$cfg->{"styles"}{"print"}
Truth table50%1/2
A
A= $cfg->{"styles"}{"print"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | my %styles = %{ $cfg->{styles} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | my @styles = ( "default" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | for ( sort keys %styles ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 15 | ▶ | next if /^(?:default|embed)$/ ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 9 | ▶ | next unless $styles{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | push( @styles, $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | push( @book, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | '<html>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | '<head>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | '<meta charset="utf-8">' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | if ( delete $styles{embed} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use File::LoadLines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | foreach my $class ( @styles ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $style = CP->findres( $styles{$class}, class => "styles" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | next unless fs_test( 'rf', $style ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my @lines = loadlines($style, { fail => 'hard' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | push( @book, "<style type=\"text/css\" ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ($class eq "default" ? "" : "media=\"$class\"").">", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | @lines, "</style>" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | delete $styles{$class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | foreach ( @styles ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | ▶ | next unless $styles{$_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | push( @book, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | ▶ | '<link rel="stylesheet" href="'.$styles{$_}.'"'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ( $_ =~ /^(default)$/ ? "" : qq{ media="$_"} ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | '>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | push( @book, '</head>', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | '<body>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | foreach my $song ( @{$sb->{songs}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | push( @book, @{ generate_song($song) } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | push( @book, "</body>", "</html>" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | \@book; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | my $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | my $single_space = 0; # suppress chords line when empty | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | my $lyrics_only = 0; # suppress all chords lines | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | my $layout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | ▶ | sub generate_song { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_song: called CC=62 SCAR=69.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | my ( $s ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | my $tidy = $::options->{tidy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | $single_space = $::options->{'single-space'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | $config = dclone( $s->{config} // $::config ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$s->{"config"} // $main::config
MC/DC0%0/2
$s->{"config"} // $main::config
$s->{"config"}
$main::config
Truth table33%1/3
A // B
A= $s->{"config"}B= $main::config
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | $lyrics_only = $config->{settings}->{'lyrics-only'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 3 | $s->structurize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | prepare_assets($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | ▶ | $s->dump(0) if $config->{debug}->{song}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | $layout = Text::Layout::HTML->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | while ( my($k,$v) = each( %{$config->{markup}->{shortcodes}}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | unless ( $layout->can("register_shortcode") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | warn("Cannot register shortcodes, upgrade Text::Layout module\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $layout->register_shortcode( $k, $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | ▶ | for ( $s->{title} // "Untitled" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$s->{"title"} // "Untitled"
MC/DC0%0/1
$s->{"title"} // "Untitled"
$s->{"title"}
Truth table50%1/2
A
A= $s->{"title"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | push( @s, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | '<div class="song">', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | '<style>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | '@page {', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ' @top-center {', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ' content: counter(song) ". ' . $_ . '";', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ' }', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | '}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | '</style>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | '<div class="title">' . nhtml($_) . '</div>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | if ( defined $s->{subtitle} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | map { '<div class="subtitle">' . nhtml($_) . '</div>' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | @{$s->{subtitle}} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | my @elts = @{$s->{body}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | ▶ | while ( @elts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 30 | my $elt = shift(@elts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 30 | ▶ | if ( $elt->{type} eq "empty" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | push(@s, "***SHOULD NOT HAPPEN***"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 30 | ▶ | if ( $elt->{type} eq "colb" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # push(@s, "{column_break}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 27 | ▶ | if ( $elt->{type} eq "newpage" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # push(@s, "{new_page}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 24 | ▶ | if ( $elt->{type} eq "songline" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | push(@s, songline( $s, $elt )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 24 | ▶ | if ( $elt->{type} eq "tab" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $p = '<div class="tab">'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | foreach ( @{ $elt->{body} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | next if $_->{type} eq "set"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | push( @s, $p . html($_->{text}) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $p = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | push( @s, $p . '</div>' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | push( @s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 24 | ▶ | if ( exists $elt->{body} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 12 | push( @s, '<div class="' . $elt->{type} . '">' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 12 | my @elts = @{$elt->{body}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 12 | ▶ | while ( @elts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 51 | my $e = shift(@elts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 51 | ▶ | if ( $e->{type} eq "empty" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | push( @s, "<!-- ***SHOULD NOT HAPPEN*** -->" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 51 | ▶ | if ( $e->{type} eq "songline" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 48 | push( @s, songline( $s, $e ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 48 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | ▶ | if ( $e->{type} =~ /^comment(_\w+)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | '<div class="' . $e->{type} . '">' . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | '<span>' . nhtml($e->{text}) . '</span></div>' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | if ( $e->{type} eq "set" && $e->{name} eq "label" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$e->{"type"} eq "set" and $e->{"name"} eq "label"
MC/DC0%0/2
$e->{"type"} eq "set" and $e->{"name"} eq "label"
$e->{"type"} eq "set"
$e->{"name"} eq "label"
Truth table33%1/3
A and B
A= $e->{"type"} eq "set"B= $e->{"name"} eq "label"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | '<div class="label">' . nhtml($e->{value}) . '</div>' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | if ( $e->{type} eq "delegate" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$e->{"type"} eq "delegate" and $e->{"subtype"} =~ /^image(?:-(\w+))?$/
MC/DC0%0/2
$e->{"type"} eq "delegate" and $e->{"subtype"} =~ /^image(?:-(\w+))?$/
$e->{"type"} eq "delegate"
$e->{"subtype"} =~ /^image(?:-(\w+))?$/
Truth table33%1/3
A and B
A= $e->{"type"} eq "delegate"B= $e->{"subtype"} =~ /^image(?:-(\w+))?$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | && $e->{subtype} =~ /^image(?:-(\w+))?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my $delegate = $1 // $e->{delegate}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$1 // $e->{"delegate"}
MC/DC0%0/2
$1 // $e->{"delegate"}
$1
$e->{"delegate"}
Truth table0%0/3
A // B
A= $1B= $e->{"delegate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $pkg = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $pkg =~ s/::Output::\w+$/::Delegate::$delegate/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | eval "require $pkg" || die($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my $hd = $pkg->can($e->{handler}) // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$pkg->can($e->{"handler"}) // die(qq[HTML: Missing delegate handler ${pkg}::$e->{"handler"}\n])
MC/DC0%0/2
$pkg->can($e->{"handler"}) // die(qq[HTML: Missing delegate handler ${pkg}::$e->{"handler"}\n])
$pkg->can($e->{"handler"})
die(qq[HTML: Missing delegate handler ${pkg}::$e->{"handler"}\n])
Truth table0%0/3
A // B
A= $pkg->can($e->{"handler"})B= die(qq[HTML: Missing delegate handler ${pkg}::$e->{"handler"}\n])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | die("HTML: Missing delegate handler ${pkg}::$e->{handler}\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $res = $hd->( $s, 0, $e ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | next unless $res; # assume errors have been given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | unshift( @elts, @$res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | ▶ | if ( $e->{type} eq "svg" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | push( @s, '<div class="' . $e->{type} . '">' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | push( @s, fs_load( $e->{uri} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | push( @s, "</div>" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 3 | ▶ | if ( $e->{type} eq "image" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | ▶ | use ChordPro::Output::Common qw(mimedata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | while ( my($k,$v) = each( %{ $e->{opts} } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | push( @args, "$k=\"$v\"" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $asset = $s->{assets}->{$e->{id}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $e->{uri} //= $asset->{uri}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$e->{"uri"} //= $asset->{"uri"}
MC/DC0%0/2
$e->{"uri"} //= $asset->{"uri"}
$e->{"uri"}
$asset->{"uri"}
Truth table0%0/3
A //= B
A= $e->{"uri"}B= $asset->{"uri"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my @images; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( $s->{assets}->{$e->{id}}->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # mimedata will return one or more image sources. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | @images = mimedata( \join("\n",@{$asset->{data}}) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Presumably a single image source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | @images = mimedata($e->{uri}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | for ( @images ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | '<div class="' . $e->{type} . '">' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | qq{<img src="$_" } . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | "@args" . "/>" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | '</div>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | if ( $e->{type} eq "html" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | while ( my($k,$v) = each( %{ $e->{opts} } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | push( @args, "$k=\"$v\"" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | use ChordPro::Delegate::TextBlock; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $pkg = 'ChordPro::Delegate::'. $e->{delegate}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $hnd = $e->{handler}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $res = $pkg->can($hnd)->( $s, elt => $e ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | push( @s, '<div class="' . lc($hnd) . '">' . $_ . '</div>' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | for @{$res->{data}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 12 | push( @s, '</div>' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 12 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 12 | ▶ | if ( $elt->{type} eq "comment" || $elt->{type} eq "comment_italic" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$elt->{"type"} eq "comment" or $elt->{"type"} eq "comment_italic"
MC/DC0%0/2
$elt->{"type"} eq "comment" or $elt->{"type"} eq "comment_italic"
$elt->{"type"} eq "comment"
$elt->{"type"} eq "comment_italic"
Truth table66%2/3
A or B
A= $elt->{"type"} eq "comment"B= $elt->{"type"} eq "comment_italic"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 12 | ▶ | if ( $elt->{chords} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $t = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | for ( my $i=0; $i < @{$elt->{chords}}; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | $t .= $s->{chordsinfo}->{$elt->{chords}->[$i]->key}->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if $elt->{chords}->[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $t .= $elt->{phrases}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | push( @s, '<div class="' . $elt->{type} . '"><span>' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | nhtml($t) . '</span></div>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | '<div class="' . $elt->{type} . '">' . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 12 | '<span>' . nhtml(fmt_subst($s,$elt->{text})) . '</span></div>' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 12 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ( $elt->{type} eq "image" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | use ChordPro::Output::Common qw(mimedata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | while ( my($k,$v) = each( %{ $elt->{opts} } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | push( @args, "$k=\"$v\"" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $asset = $s->{assets}->{$elt->{id}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $elt->{uri} //= $asset->{uri}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$elt->{"uri"} //= $asset->{"uri"}
MC/DC0%0/2
$elt->{"uri"} //= $asset->{"uri"}
$elt->{"uri"}
$asset->{"uri"}
Truth table0%0/3
A //= B
A= $elt->{"uri"}B= $asset->{"uri"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my @images; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ( $s->{assets}->{$elt->{id}}->{data} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | @images = mimedata( \$asset->{data} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | @images = mimedata($elt->{uri}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | for ( @images ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | push( @s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | '<div class="' . $elt->{type} . '">' . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | qq{<img src="$_" } . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | "@args" . "/>" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | '</div>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if ( $elt->{type} eq "html" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | while ( my($k,$v) = each( %{ $elt->{opts} } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | push( @args, "$k=\"$v\"" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $pkg = 'ChordPro::Delegate::'. $elt->{delegate}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $hnd = $elt->{handler}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $html = $pkg->can($hnd)->( $s, elt => $elt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | push( @s, '<div class="' . lc($hnd) . '">' . $html . '</div>' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | push( @s, "" ) if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ( $elt->{type} eq "control" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ( $elt->{name} eq "lyrics-only" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | $lyrics_only = $elt->{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | unless $lyrics_only > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 3 | push( @s, '</div>' ); # song | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 3 | \@s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 48 | ▶ | sub songline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
songline: called CC=12 SCAR=25.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 48 | my ( $song, $elt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 48 | my $t_line = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 48 | ▶ | $elt->{chords} //= [ '' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$elt->{"chords"} //= [""]
MC/DC100%1/1
$elt->{"chords"} //= [""]
$elt->{"chords"}
Truth table100%2/2
A
A= $elt->{"chords"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | my @c = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 111 | ▶ | $_ eq "" ? "" : $song->{chordsinfo}->{$_->key }->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 48 | } @{ $elt->{chords} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 48 | ▶ | if ( $lyrics_only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$lyrics_only or $single_space and not $elt->{"chords"} && join("", @c) =~ /\S/
$single_space and not $elt->{"chords"} && join("", @c) =~ /\S/
$elt->{'chords'} && join('', @c) =~ /\S/
MC/DC75%3/4
$lyrics_only or $single_space and not $elt->{"chords"} && join("", @c) =~ /\S/
$lyrics_only
$single_space
$elt->{'chords'}
join('', @c) =~ /\S/
Truth table80%4/5
A or B and not(C && D)
A= $lyrics_onlyB= $single_spaceC= $elt->{'chords'}D= join('', @c) =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $single_space && ! ( $elt->{chords} && join( "", @c ) =~ /\S/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 24 | $t_line = join( "", @{ $elt->{phrases} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 24 | $t_line =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 24 | return ( '<table class="songline">', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ' <tr class="lyrics">', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ' <td>' . nhtml($t_line) . '</td>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ' </tr>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | '</table>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 24 | my $cr = ""; # chords row | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 24 | for ( @{$elt->{chords}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 66 | ▶ | if ( $_ eq "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 24 | $cr .= "<td></td>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 24 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 42 | my $c = $song->{chordsinfo}->{$_->key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 42 | ▶ | if ( $c->isa("ChordPro::Chord::Annotation") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $cr .= "<td class=\"annotation\">" . $c->{text} . "</td>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 42 | $cr .= "<td>" . $c->name . "</td>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | my $pr = join( '', # phrases row | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 66 | ▶ | map { ( $_ =~ s/^\s+// ? '<td class="indent">' : '<td>' ) . nhtml($_) . '</td>' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 24 | ( @{ $elt->{phrases} } ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 24 | ▶ | if ( $config->{settings}->{'chords-under'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | return ( '<table class="songline">', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ' <tr class="lyrics">', ' ' . $pr, ' </tr>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | ' <tr class="chords">', ' ' . $cr, ' </tr>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | '</table>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 24 | return ( '<table class="songline">', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ' <tr class="chords">', ' ' . $cr, ' </tr>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ' <tr class="lyrics">', ' ' . $pr, ' </tr>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | '</table>' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | =for later | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | sub gridline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | <style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | div.grid_2_4x4_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | display: grid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | grid-template-columns: 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263% 5.263%; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | div.grid_2_4x4_1 div { padding: 4px } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | div.grid_2_4x4_1 div.A { grid-column: span 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | div.grid_2_4x4_1 div.L { border-left: 1px solid black } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | div.grid_2_4x4_1 div.M { border-left: 1px solid #e0e0e0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | div.grid_2_4x4_1 div.R { border-right: 1px solid black } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | div.grid_2_4x4_1 div.Z { grid-column: span 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | </style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | <div class="grid_2_4x4_1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | <div class="A">intro</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | <div class="L">a1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | <div class="M">a2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | <div class="M">a3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | <div class="M">a4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | <div class="L">b1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | <div class="M">b2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | <div class="M">b3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | <div class="M">b4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | <div class="L">c1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | <div class="M">c2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | <div class="M">c3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | <div class="M">c4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | <div class="L">d1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | <div class="M">d2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | <div class="M">d3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | <div class="M R">d4 d4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | <div class="Z"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | <div class="A"></div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | <div class="L">a1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | <div class="M">a2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | <div class="M">a3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | <div class="M">a4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | <div class="L">b1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | <div class="M">b2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | <div class="M">b3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | <div class="M">b4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | <div class="L">c1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | <div class="M">c2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | <div class="M">c3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | <div class="M">c4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | <div class="L">d1</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | <div class="M">d2</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | <div class="M">d3</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | <div class="M R">d4</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | <div class="Z">2x</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 108 | ▶ | sub nhtml { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nhtml: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 108 | ▶ | return unless defined $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 108 | $layout->set_markup(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 108 | $layout->render; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 102 | ▶ | sub html { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 102 | my $t = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 102 | $t =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 102 | $t =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 102 | $t =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 102 | $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # Temporary. Eventually we'll have a decent HTML backend for Text::Layout. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | package Text::Layout::HTML; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | ▶ | use parent 'Text::Layout'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 2 | ▶ | use ChordPro::Utils qw(fq); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | # Eliminate warning when HTML backend is loaded together with Text backend. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | my ( $pkg, @data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 3 | my $self = $pkg->SUPER::new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | $self->{_currentfont} = { family => 'default', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | style => 'normal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | weight => 'normal' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | $self->{_currentcolor} = 'black'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 3 | $self->{_currentsize} = 12; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 3 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 2 | *html = \&ChordPro::Output::HTML::html; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 108 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=22 SCAR=42.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 108 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 108 | my $res = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 108 | foreach my $fragment ( @{ $self->{_content} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 102 | ▶ | if ( $fragment->{type} eq 'strut' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | next unless length($fragment->{label}//""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$fragment->{"label"} // ""
MC/DC0%0/1
$fragment->{"label"} // ""
$fragment->{"label"}
Truth table0%0/2
A
A= $fragment->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $res .= "<span id=\"".$fragment->{label}."\"/>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 102 | ▶ | next unless length($fragment->{text}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 102 | ▶ | my $f = $fragment->{font} || $self->{_currentfont}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$fragment->{'font'} || $self->{'_currentfont'}
MC/DC0%0/2
$fragment->{'font'} || $self->{'_currentfont'}
$fragment->{'font'}
$self->{'_currentfont'}
Truth table33%1/3
A || B
A= $fragment->{'font'}B= $self->{'_currentfont'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 102 | my @c; # styles | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | my @d; # decorations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 102 | ▶ | if ( $f->{style} eq "italic" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | push( @c, q{font-style:italic} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 102 | ▶ | if ( $f->{weight} eq "bold" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | push( @c, q{font-weight:bold} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 102 | ▶ | if ( $fragment->{color} && $fragment->{color} ne $self->{_currentcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fragment->{"color"} and $fragment->{"color"} ne $self->{"_currentcolor"}
MC/DC0%0/2
$fragment->{"color"} and $fragment->{"color"} ne $self->{"_currentcolor"}
$fragment->{"color"}
$fragment->{"color"} ne $self->{"_currentcolor"}
Truth table33%1/3
A and B
A= $fragment->{"color"}B= $fragment->{"color"} ne $self->{"_currentcolor"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | push( @c, join(":","color",$fragment->{color}) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 102 | ▶ | if ( $fragment->{size} && $fragment->{size} ne $self->{_currentsize} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fragment->{"size"} and $fragment->{"size"} ne $self->{"_currentsize"}
MC/DC0%0/2
$fragment->{"size"} and $fragment->{"size"} ne $self->{"_currentsize"}
$fragment->{"size"}
$fragment->{"size"} ne $self->{"_currentsize"}
Truth table33%1/3
A and B
A= $fragment->{"size"}B= $fragment->{"size"} ne $self->{"_currentsize"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | push( @c, join(":","font-size",$fragment->{size}) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 102 | ▶ | if ( $fragment->{bgcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | push( @c, join(":","background-color",$fragment->{bgcolor}) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 102 | ▶ | if ( $fragment->{underline} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | push( @d, q{underline} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 102 | ▶ | if ( $fragment->{strikethrough} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | push( @d, q{line-through} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 102 | ▶ | push( @c, "text-decoration-line:@d" ) if @d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 102 | ▶ | my $href = $fragment->{href} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$fragment->{"href"} // ""
MC/DC0%0/1
$fragment->{"href"} // ""
$fragment->{"href"}
Truth table50%1/2
A
A= $fragment->{"href"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 102 | ▶ | $res .= "<a href=\"".html($href)."\">" if length($href); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 102 | ▶ | $res .= "<span$href style=\"" . join(";",@c) . "\">" if @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 102 | $res .= html(fq($fragment->{text})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 102 | ▶ | $res .= "</span>" if @c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 102 | ▶ | $res .= "</a>" if length($href); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 108 | $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||