| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | our $options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | our $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | package ChordPro::Output::Text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use ChordPro::Output::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 21 | ▶ | sub generate_songbook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_songbook: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 21 | my ( $self, $sb ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 21 | my @book; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 21 | foreach my $song ( @{$sb->{songs}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 21 | ▶ | if ( @book ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | push(@book, "") if $options->{'backend-option'}->{tidy}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | push(@book, "-- New song"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 21 | push(@book, @{generate_song($song)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 21 | push( @book, ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 21 | \@book; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | my $single_space = 0; # suppress chords line when empty | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | my $lyrics_only = 0; # suppress all chords lines | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | my $chords_under = 0; # chords under lyrics | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | my $layout = Text::Layout::Text->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | my $rechorus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 24 | ▶ | sub upd_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upd_config: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 24 | $lyrics_only = $config->{settings}->{'lyrics-only'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 24 | $chords_under = $config->{settings}->{'chords-under'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 24 | $rechorus = $config->{text}->{chorus}->{recall}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 21 | ▶ | sub generate_song { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_song: called CC=57 SCAR=59.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 21 | my ( $s ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 21 | $config = $s->{config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 21 | my $tidy = $options->{'backend-option'}->{tidy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 21 | $single_space = $options->{'single-space'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 21 | upd_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $s->structurize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 21 | ▶ | if ( $options->{'backend-option'}->{structure} // '' ) eq 'structured'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$main::options->{"backend-option"}{"structure"} // ""
MC/DC0%0/1
$main::options->{"backend-option"}{"structure"} // ""
$main::options->{"backend-option"}{"structure"}
Truth table50%1/2
A
A= $main::options->{"backend-option"}{"structure"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 21 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | push(@s, "-- Title: " . $s->{title}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 21 | ▶ | if defined $s->{title}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 21 | ▶ | if ( defined $s->{subtitle} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | push(@s, map { +"-- Subtitle: $_" } @{$s->{subtitle}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 21 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 21 | my $ctx = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 21 | my @elts = @{$s->{body}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 21 | ▶ | while ( @elts ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 321 | my $elt = shift(@elts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 321 | ▶ | if ( $elt->{context} ne $ctx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 54 | ▶ | push(@s, "-- End of $ctx") if $ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 54 | ▶ | push(@s, "-- Start of $ctx") if $ctx = $elt->{context}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 321 | ▶ | if ( $elt->{type} eq "empty" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | push(@s, "***SHOULD NOT HAPPEN***") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 81 | ▶ | if $s->{structure} eq 'structured'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 81 | push(@s, ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 81 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 240 | ▶ | if ( $elt->{type} eq "colb" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | push(@s, "-- Column break"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 237 | ▶ | if ( $elt->{type} eq "newpage" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | push(@s, "-- New page"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 234 | ▶ | if ( $elt->{type} eq "songline" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 105 | push(@s, songline( $s, $elt )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 105 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 129 | ▶ | if ( $elt->{type} eq "tabline" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 24 | push(@s, $elt->{text}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 24 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 105 | ▶ | if ( $elt->{type} eq "chorus" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | push(@s, "-- Start of chorus*"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | foreach my $e ( @{$elt->{body}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $e->{type} eq "empty" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | push(@s, ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( $e->{type} eq "songline" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | push(@s, songline( $s, $e )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | push(@s, "-- End of chorus*"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 105 | ▶ | if ( $elt->{type} eq "rechorus" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 15 | ▶ | if ( $rechorus->{quote} && $elt->{chorus} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$rechorus->{"quote"} and $elt->{"chorus"}
MC/DC0%0/2
$rechorus->{"quote"} and $elt->{"chorus"}
$rechorus->{"quote"}
$elt->{"chorus"}
Truth table33%1/3
A and B
A= $rechorus->{"quote"}B= $elt->{"chorus"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 15 | unshift( @elts, @{ $elt->{chorus} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ▶ | elsif ( $rechorus->{type} && $rechorus->{tag} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rechorus->{"type"} and $rechorus->{"tag"}
MC/DC0%0/2
$rechorus->{"type"} and $rechorus->{"tag"}
$rechorus->{"type"}
$rechorus->{"tag"}
Truth table0%0/3
A and B
A= $rechorus->{"type"}B= $rechorus->{"tag"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | push( @s, "{".$rechorus->{type}.": ".$rechorus->{tag}."}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | push( @s, "{chorus}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 15 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 90 | ▶ | if ( $elt->{type} eq "tab" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | push(@s, "-- Start of tab"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | push(@s, map { $_->{text} } @{$elt->{body}} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | push(@s, "-- End of tab"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 90 | ▶ | if ( $elt->{type} eq "verse" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | push(@s, "-- Start of verse"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | foreach my $e ( @{$elt->{body}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ( $e->{type} eq "empty" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | push(@s, "***SHOULD NOT HAPPEN***") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if $s->{structure} eq 'structured'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ( $e->{type} eq "songline" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | push(@s, songline( $s, $e )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ( $e->{type} eq "comment" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | push(@s, "-c- " . $e->{text}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ( $e->{type} eq "comment_italic" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | push(@s, "-i- " . $e->{text}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | push(@s, "-- End of verse"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 90 | ▶ | if ( $elt->{type} =~ /^comment(?:_italic|_box)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 42 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 42 | my $text = $elt->{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 42 | ▶ | if ( $elt->{chords} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 12 | $text = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 12 | for ( 0..$#{ $elt->{chords} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $text .= "[" . $elt->{chords}->[$_]->key . "]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 24 | ▶ | if $elt->{chords}->[$_] ne ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 24 | $text .= $elt->{phrases}->[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # $text = fmt_subst( $s, $text ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 42 | push(@s, "-- $text"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 42 | ▶ | push(@s, "") if $tidy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 42 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 48 | ▶ | if ( $elt->{type} eq "image" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | my @args = ( "image:", $elt->{uri} // "<none>" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$elt->{"uri"} // "<none>"
MC/DC0%0/1
$elt->{"uri"} // "<none>"
$elt->{"uri"}
Truth table0%0/2
A
A= $elt->{"uri"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | while ( my($k,$v) = each( %{ $elt->{opts} } ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | push( @args, "$k=$v" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | foreach ( @args ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | next unless /\s/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $_ = '"' . $_ . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | push( @s, "+ @args" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 48 | ▶ | if ( $elt->{type} eq "set" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 33 | ▶ | if ( $elt->{name} eq "lyrics-only" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $lyrics_only = $elt->{value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | unless $lyrics_only > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Arbitrary config values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | elsif ( $elt->{name} =~ /^(text\..+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | my @k = split( /[.]/, $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | my $cc = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | my $c = \$cc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 3 | foreach ( @k ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 12 | $c = \($$c->{$_}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | $$c = $elt->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | $config->augment($cc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | upd_config(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 33 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 15 | ▶ | if ( $elt->{type} eq "control" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 21 | ▶ | push(@s, "-- End of $ctx") if $ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 21 | \@s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 105 | ▶ | sub songline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
songline: called CC=18 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 105 | my ( $song, $elt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 105 | my $t_line = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 330 | my @phrases = map { $layout->set_markup($_); $layout->render } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 105 | @{ $elt->{phrases} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 105 | ▶ | if ( $lyrics_only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$lyrics_only or $single_space and not $elt->{"chords"} && join("", map({$_ ? $_->key : "";} @{$$elt{"chords"};})) =~ /\S/
$single_space and not $elt->{"chords"} && join("", map({$_ ? $_->key : "";} @{$$elt{"chords"};})) =~ /\S/
$elt->{'chords'} && join('', map({$_ ? $_->key : '';} @{$$elt{'chords'};})) =~ /\S/
MC/DC75%3/4
$lyrics_only or $single_space and not $elt->{"chords"} && join("", map({$_ ? $_->key : "";} @{$$elt{"chords"};})) =~ /\S/
$lyrics_only
$single_space
$elt->{'chords'}
join('', map({$_ ? $_->key : '';} @{$$elt{'chords'};})) =~ /\S/
Truth table80%4/5
A or B and not(C && D)
A= $lyrics_onlyB= $single_spaceC= $elt->{'chords'}D= join('', map({$_ ? $_->key : '';} @{$$elt{'chords'};})) =~ /\S/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 102 | ▶ | $single_space && ! ( $elt->{chords} && join( "", map { $_?$_->key:"" } @{ $elt->{chords} } ) =~ /\S/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 43 | $t_line = join( "", @phrases ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 43 | $t_line =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 43 | return $t_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 62 | ▶ | unless ( $elt->{chords} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 8 | ▶ | return ( $config->{settings}->{'inline-chords'} ? () : "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | join( " ", @phrases ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 54 | ▶ | if ( my $f = $config->{settings}->{'inline-chords'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $f = '[%s]' unless $f =~ /^[^%]*\%s[^%]*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $f .= '%s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | foreach ( 0..$#{$elt->{chords}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ( $elt->{chords}->[$_] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | $t_line .= sprintf( $f, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | chord( $song, $elt->{chords}->[$_] ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | $phrases[$_] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $t_line .= $phrases[$_]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | return ( $t_line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 54 | my $c_line = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 54 | foreach my $c ( 0..$#{$elt->{chords}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | $c_line .= chord( $song, $elt->{chords}->[$c] ) . " " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 204 | ▶ | if ref $elt->{chords}->[$c]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 204 | $t_line .= $phrases[$c]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 204 | my $d = length($c_line) - length($t_line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 204 | ▶ | $t_line .= "-" x $d if $d > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 204 | ▶ | $c_line .= " " x -$d if $d < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 54 | s/\s+$// for ( $t_line, $c_line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 54 | ▶ | return $chords_under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ? ( $t_line, $c_line ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | : ( $c_line, $t_line ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 150 | ▶ | sub chord { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chord: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 150 | my ( $s, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 150 | ▶ | return "" unless length($c); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 150 | $layout->set_markup($c->chord_display); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 150 | my $t = $layout->render; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 150 | ▶ | return $c->info->is_annotation ? "*$t" : $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # Temporary. Eventually we'll have a decent HTML backend for Text::Layout. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | package Text::Layout::Text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | ▶ | use parent 'Text::Layout'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | ▶ | use ChordPro::Utils qw( fq ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # Eliminate warning when HTML backend is loaded together with Text backend. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | my ( $pkg, @data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | my $self = $pkg->SUPER::new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 480 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 480 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 480 | my $res = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 480 | foreach my $fragment ( @{ $self->{_content} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 474 | ▶ | next unless length($fragment->{text}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 474 | $res .= fq($fragment->{text}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 480 | $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||