App-Ikachan
view release on metacpan or search on metacpan
inc/Module/Install/Metadata.pm view on Meta::CPAN
# It's in core of perl >= 5.9.3, and should be installed
# as one of the Pod::Simple's prereqs, which is a prereq
# of Pod::Text 3.x (see also below).
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> }
{
defined $2
? chr($2)
: defined $Pod::Escapes::Name2character_number{$1}
? chr($Pod::Escapes::Name2character_number{$1})
: do {
warn "Unknown escape: E<$1>";
"E<$1>";
};
}gex;
}
elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) {
# Pod::Text < 3.0 has yet another mapping table,
# though the table name of 2.x and 1.x are different.
# (1.x is in core of Perl < 5.6, 2.x is in core of
# Perl < 5.9.3)
my $mapping = ($Pod::Text::VERSION < 2)
? \%Pod::Text::HTML_Escapes
: \%Pod::Text::ESCAPES;
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> }
{
defined $2
? chr($2)
: defined $mapping->{$1}
? $mapping->{$1}
: do {
warn "Unknown escape: E<$1>";
"E<$1>";
};
}gex;
}
else {
$author =~ s{E<lt>}{<}g;
$author =~ s{E<gt>}{>}g;
}
$self->author($author);
} else {
inc/Pod/Markdown.pm view on Meta::CPAN
return wantarray ? @lines : join("\n", @lines);
}
sub _clean_text {
my $text = $_[1];
my @trimmed = grep { $_; } split(/\n/, $text);
return wantarray ? @trimmed : join("\n", @trimmed);
}
sub _escape {
local $_ = $_[1];
# do inline characters first
s/([][\\`*_#])/\\$1/g;
# escape unordered lists and blockquotes
s/^([-+*>])/\\$1/mg;
# escape dots that would wrongfully create numbered lists
s/^( (?:>\s+)? \d+ ) (\.\x20)/$1\\$2/xgm;
return $_;
}
sub command {
my ($parser, $command, $paragraph, $line_num) = @_;
my $data = $parser->_private;
# cleaning the text
$paragraph = $parser->_clean_text($paragraph);
# is it a header ?
if ($command =~ m{head(\d)}xms) {
my $level = $1;
$paragraph = $parser->_escape_and_interpolate($paragraph, $line_num);
# the headers never are indented
$parser->_save($parser->format_header($level, $paragraph));
if ($level == 1) {
if ($paragraph =~ m{NAME}xmsi) {
$data->{searching} = 'title';
} elsif ($paragraph =~ m{AUTHOR}xmsi) {
$data->{searching} = 'author';
} else {
$data->{searching} = '';
inc/Pod/Markdown.pm view on Meta::CPAN
if( (my $smallest = length($indent)) < 4 ){
# invert to get what needs to be prepended
$indent = ' ' x (4 - $smallest);
# leave tabs alone
$paragraph = join "\n", map { /^\t/ ? $_ : $indent . $_ } @lines;
}
$parser->_save($paragraph);
}
sub _escape_and_interpolate {
my ($parser, $paragraph, $line_num) = @_;
# escape markdown characters in text sequences except for inline code
$paragraph = join '', $parser->parse_text(
{ -expand_text => '_escape_non_code' },
$paragraph, $line_num
)->raw_text;
# interpolate the paragraph for embedded sequences
$paragraph = $parser->interpolate($paragraph, $line_num);
return $paragraph;
}
sub _escape_non_code {
my ($parser, $text, $ptree) = @_;
$text = $parser->_escape($text)
unless $ptree->isa('Pod::InteriorSequence') && $ptree->cmd_name eq 'C';
return $text;
}
sub textblock {
my ($parser, $paragraph, $line_num) = @_;
my $data = $parser->_private;
my $prelisthead;
$paragraph = $parser->_escape_and_interpolate($paragraph, $line_num);
# clean the empty lines
$paragraph = $parser->_clean_text($paragraph);
# searching ?
if ($data->{searching} =~ m{title|author}xms) {
$data->{ ucfirst $data->{searching} } = $paragraph;
$data->{searching} = '';
} elsif ($data->{searching} =~ m{listhead(huddled)?$}xms) {
my $is_huddled = $1;
inc/Pod/Markdown.pm view on Meta::CPAN
$url = 'http://man.he.net/man' . ($part || 1) . '/' . ($page || $name);
} else {
if ($name) {
$url = 'http://search.cpan.org/perldoc?' . $name;
}
if ($section){
# TODO: sites/pod formatters differ on how to transform the section
# TODO: we could do it according to specified url prefix or pod formatter
# TODO: or allow a coderef?
# TODO: (Pod::Simple::XHTML:idify() for metacpan)
# TODO: (Pod::Simple::HTML section_escape/unicode_escape_url/section_url_escape for s.c.o.)
$url .= '#' . $section;
}
}
# if we don't know how to handle the url just print the pod back out
if (!$url) {
return sprintf '%s<%s>', $cmd, $arg;
}
return sprintf '[%s](%s)', ($text || $inferred), $url;
( run in 0.401 second using v1.01-cache-2.11-cpan-c21f80fb71c )