App-MakeEPUB
view release on metacpan or search on metacpan
examples/rfc/bin/rfc2xhtml.pl view on Meta::CPAN
sub _begin_toc {
my ($self,$event,$line,$args) = @_;
$self->{lasttext} = [];
print qq(<h2><a id="section-toc">$line</a></h2>\n<ul>\n);
} # _begin_toc()
sub _catch_unfinished_paragraph {
my ($self) = @_;
my $prevtext = $self->{prevtext};
my $lasttext = $self->{lasttext};
my @lines = map { _escape($_->{text}) } @$lasttext;
if (0 < scalar @$prevtext) { # we had an old unfinished paragraph
if (_is_image(@lines)
or _is_different_indent($prevtext,$lasttext)) {
$self->{lasttext} = $prevtext;
$self->{prevtext} = [];
$self->{forceprint} = 1;
$self->_print_paragraph();
$self->{lasttext} = $lasttext;
$self->{forceprint} = 0;
examples/rfc/bin/rfc2xhtml.pl view on Meta::CPAN
return;
} # _collect_text()
sub _end_toc_h2 {
my ($self,$event,$line,$args) = @_;
my $id = $args->{id} || '';
$self->{lasttext} = [];
print qq(</ul>\n<h2><a id="section-$id">$line</a></h2>\n);
} # _end_toc_h2()
sub _escape {
my ($text) = @_;
$text =~ s/</</g;
return $text;
} # _escape()
sub _init {
my ($self,$args) = @_;
$self->{xmlns} = "http://www.w3.org/1999/xhtml";
$self->{indent} = 0;
$self->{lasttext} = [];
$self->{prevtext} = [];
$self->{title} = $args->{title} ? $args->{title}
: $self->{title} ? $self->{title}
examples/rfc/bin/rfc2xhtml.pl view on Meta::CPAN
and not _is_image(@_)
and ($_[$#_] !~ /[.:)\]]\s*$/));
return $unfinished;
} # _is_unfinished()
sub _print_paragraph {
my ($self) = @_;
$self->_catch_unfinished_paragraph();
my $lasttext = $self->{lasttext};
my @lines = map { _escape($_->{text}) } @$lasttext;
# Heuristic: If a single line ends without a dot, it probably won't be an
# unfinished paragraph.
#
if (not $self->{forceprint}
and 1 < scalar @lines
and _is_unfinished(@lines)) {
$self->{prevtext} = $lasttext;
$self->{lasttext} = [];
$lasttext = [];
}
if (0 == scalar @$lasttext) {
return;
}
if (_is_image(@lines)) {
my $fig = "<pre>\n";
foreach my $line (@$lasttext) {
$fig .= " " x $line->{indent};
$fig .= _escape($line->{text}) . "\n";
}
print $fig . "</pre>\n";
}
elsif (0 < $#lines
and $lasttext->[0]->{indent} + 4 == $lasttext->[1]->{indent}) {
my $first = shift @lines;
my $class = 'term';
my $fline = "<b>$first</b><br />";
if ($lasttext->[0]->{text} =~ /^o /) {
$class = 'list';
( run in 0.351 second using v1.01-cache-2.11-cpan-c21f80fb71c )