App-Ikachan
view release on metacpan or search on metacpan
inc/Pod/Markdown.pm view on Meta::CPAN
#line 1
# vim: set ts=4 sts=4 sw=4 expandtab smarttab:
#
# This file is part of Pod-Markdown
#
# This software is copyright (c) 2004 by Marcel Gruenauer.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use 5.008;
use strict;
use warnings;
package Pod::Markdown;
{
$Pod::Markdown::VERSION = '1.322';
}
# git description: v1.321-4-geed8814
BEGIN {
$Pod::Markdown::AUTHORITY = 'cpan:RWSTAUNER';
}
# ABSTRACT: Convert POD to Markdown
use parent qw(Pod::Parser);
use Pod::ParseLink (); # core
sub initialize {
my $self = shift;
$self->SUPER::initialize(@_);
$self->_private;
$self;
}
sub _private {
my $self = shift;
$self->{_MyParser} ||= {
Text => [], # final text
Indent => 0, # list indent levels counter
ListType => '-', # character on every item
searching => '' , # what are we searching for? (title, author etc.)
sstack => [] , # Stack for searching, needed for nested list
Title => undef, # page title
Author => undef, # page author
};
}
sub as_markdown {
my ($parser, %args) = @_;
my $data = $parser->_private;
my $lines = $data->{Text};
my @header;
if ($args{with_meta}) {
@header = $parser->_build_markdown_head;
}
join("\n" x 2, @header, @{$lines}) . "\n";
}
sub _build_markdown_head {
my $parser = shift;
my $data = $parser->_private;
return join "\n",
map { qq![[meta \l$_="$data->{$_}"]]! }
grep { defined $data->{$_} }
qw( Title Author );
}
# $prelisthead:
# undef : not list head
# '' : list head not huddled
# otherwise: list head huddled
sub _save {
my ($parser, $text, $prelisthead) = @_;
my $data = $parser->_private;
$text = $parser->_indent_text($text, defined($prelisthead));
$text = $prelisthead."\n".$text if defined $prelisthead && $prelisthead ne '';
push @{ $data->{Text} }, $text;
return;
}
sub _unsave {
my $parser = shift;
my $data = $parser->_private;
return pop @{ $data->{Text} };
}
sub _indent_text {
my ($parser, $text, $listhead) = @_;
my $data = $parser->_private;
my $level = $data->{Indent};
( run in 1.841 second using v1.01-cache-2.11-cpan-b16cb0d3907 )