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