package Contentment::Transform::POD2HTML; use strict; use warnings; our $VERSION = '0.16'; use Contentment; use Contentment::Setting; use base qw/ Pod::Simple /; =head1 NAME Contentment::Transform::Pod2Html - Uses Pod::Simple to create an HTML fragment =head1 DESCRIPTION This is used by the L module to create HTML fragements from POD documents in a way that is appropriate for Contentment. =cut sub _handle_element_start { my $self = shift; local $_ = shift; my $attr = shift; my $ofh = select $self->{output_fh}; my $context = Contentment->context; SWITCH: { /^Document$/ && do { print qq(
);
last SWITCH;
};
/^B$/ && do {
print qq();
last SWITCH;
};
/^I$/ && do {
print qq();
last SWITCH;
};
/^C$/ && do {
print qq();
last SWITCH;
};
/^F$/ && do {
print qq();
last SWITCH;
};
/^S$/ && do {
print qq();
last SWITCH;
};
/^X$/ && do {
$self->{'contentment_pod2html_skip_x'}++;
last SWITCH;
};
/^L$/ && do {
$self->{'contentment_pod2html_link_type'} = $attr->{type};
if ($attr->{type} eq 'url') {
print qq();
} elsif ($attr->{type} eq 'man') {
$self->{'contentment_pod2html_link_man'} = $attr->{to};
$self->{'contentment_pod2html_link_man_section'} = $attr->{section};
} elsif ($attr->{type} eq 'pod') {
my $link;
my $target;
if (defined $attr->{to}) {
my $file = $attr->{to};
$file =~ s/::/\//g;
my $settings = $context->settings;
for my $pod_base (@{ $settings->{'Contentment::Transform::POD2HTML::pod_bases'} }) {
if ($context->response->resolve("$pod_base/$file.html")) {
$link = "$pod_base/$file.html";
last;
}
}
unless (defined $link) {
$target = "_blank";
$link = "$settings->{'Contentment::Transform::POD2HTML::pod_fallback'}$attr->{to}";
}
}
if (defined $attr->{section}) {
$link .= "#$attr->{section}";
}
print qq();
} else {
warn "Unknown link type $attr->{to} given; time to update ",__PACKAGE__;
}
last SWITCH;
};
/^Verbatim$/ && do {
print qq();
last SWITCH;
};
/^head([1-4])$/ && do {
print qq(\n);
last SWITCH;
};
/^item-(bullet|number)$/ && do {
print qq(
\n);
last SWITCH;
};
/^over-text$/ && do {
$self->{'contentment_pod2html_over_text_first'}++;
print qq(
\n);
last SWITCH;
};
/^item-text$/ && do {
my $first = delete $self->{'contentment_pod2html_over_text_first'};
print qq(\n) unless defined $first;
print qq(
);
last SWITCH;
};
DEFAULT: {
warn "Unknown Pod::Simple parser event '$_'; time to update ",__PACKAGE__;
last SWITCH;
}
}
select $ofh;
}
sub _handle_element_end {
my $self = shift;
local $_ = shift;
my $ofh = select $self->{output_fh};
SWITCH: {
/^Document$/ && do {
print qq(