App-sdview
view release on metacpan or search on metacpan
lib/App/sdview/Output/Pod.pm view on Meta::CPAN
}
method output_table_mediawiki ( $para )
{
$self->say( "=begin table mediawiki" );
$self->say;
my $first = 1;
foreach my $row ( $para->rows ) {
$self->say( "|-" ) unless $first;
my @cells = @$row;
$self->say(
$_->heading ? "!" : "|",
" ",
$self->_convert_str( $_->text )
) for @cells;
undef $first;
}
$self->say;
$self->say( "=end table" );
}
method _convert_str ( $s )
{
my $ret = "";
# Paint extra "nobreak" tags on extents separated by NBSP, but leave the
# NBSP itself in the string
while( $s =~ m/\S+(?:\xA0+\S+)+/g ) {
$s->apply_tag( $-[0], $+[0]-$-[0], nobreak => 1 );
}
# TODO: This sucks for nested tags
$s->iter_substr_nooverlap(
sub ( $substr, %tags ) {
$substr =~ s/\xA0/ /g;
# Escape any literal '<'s that would otherwise break
my $pod = $substr =~ s/[A-Z]\K</E<lt>/gr;
my $count = 1;
$count++ while index( $pod, ">"x$count ) > -1;
my ( $open, $close ) =
( $count == 1 ) ? ( "<", ">" ) : ( "<"x$count . " ", " " . ">"x$count );
if( my $link = $tags{link} ) {
# TODO: This is even suckier than the bit in the parser
if( $link->{uri} eq "https://metacpan.org/pod/$substr" ) {
$pod = "L$open$substr$close";
}
else {
$pod = "L$open$pod|$link->{uri}$close";
}
}
$pod = "C$open$pod$close" if $tags{monospace};
$pod = "B$open$pod$close" if $tags{bold};
$pod = "I$open$pod$close" if $tags{italic};
$pod = "F$open$pod$close" if $tags{file};
$pod = "U$open$pod$close" if $tags{underline};
$pod = "S$open$pod$close" if $tags{nobreak};
$ret .= $pod;
}
);
return $ret;
}
=head1 AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
=cut
0x55AA;
( run in 0.489 second using v1.01-cache-2.11-cpan-39bf76dae61 )