App-Music-ChordPro
view release on metacpan or search on metacpan
lib/ChordPro/Output/Markdown.pm view on Meta::CPAN
my @s;
push(@s, "**Grid** ");
push(@s, "");
push(@s, elt_handler($lineobject->{body}));
# push(@s, "\x{00A0} ");
push(@s, "");
return @s;
}
$line_routines{line_grid} = \&line_grid;
sub line_gridline {
my ( $elt ) = @_;
my @a = @{ $elt->{tokens} };
@a = map { $_->{class} eq 'chord'
? $_->{chord}->raw
: $_->{symbol} } @a;
return "\t".join("", @a);
}
$line_routines{line_gridline} = \&line_gridline;
sub elt_handler {
my ( $elts ) = @_; # reference to array
my $cref; #command reference to subroutine
my $init_context = 1;
my $ctx = "";
my @lines;
my $last_type='';
foreach my $elt (@{ $elts }) {
if ( $elt->{type} =~ /^(ignore|meta)$/ ) {
next;
}
if (($elt->{type} eq 'verse') && ($last_type =~ /comment/)){
push(@lines, "");
}
# Gang of Four-Style - sort of command pattern
my $sub_type = "line_".$elt->{type}; # build command "line_<linetype>"
if (defined $line_routines{$sub_type}) {
$cref = $line_routines{$sub_type}; #\&$sub_type; # due to use strict - we need to get an reference to the command
push(@lines, &$cref($elt)); # call line with actual line-object
}
else {
push(@lines, line_default($elt)); # default = empty line
}
$last_type = $elt->{type};
}
return @lines;
}
#################
# package Text::Layout::Text;
# use parent 'Text::Layout';
# # Eliminate warning when HTML backend is loaded together with Text backend.
# no warnings 'redefine';
# sub new {
# my ( $pkg, @data ) = @_;
# my $self = $pkg->SUPER::new;
# $self;
# }
# sub render {
# my ( $self ) = @_;
# my $res = "";
# foreach my $fragment ( @{ $self->{_content} } ) {
# next unless length($fragment->{text});
# $res .= $fragment->{text};
# }
# $res;
# }
1;
# @todo
# sub line_rechorus {
# my ( $lineobject ) = @_;
# if ( $rechorus->{quote} ) {
# unshift( @elts, @{ $elt->{chorus} } );
# }
# elsif ( $rechorus->{type} && $rechorus->{tag} ) {
# push( @s, "{".$rechorus->{type}.": ".$rechorus->{tag}."}" );
# }
# else {
# push( @s, "{chorus}" );
# }
# }
# sub line_control {
# my ( $lineobject ) = @_;
# }
( run in 3.725 seconds using v1.01-cache-2.11-cpan-59e3e3084b8 )