package Pod::PseudoPod::HTML; use strict; use vars qw( $VERSION ); $VERSION = '0.19'; use Carp (); use base qw( Pod::PseudoPod ); use HTML::Entities 'encode_entities'; #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub new { my $self = shift; my $new = $self->SUPER::new(@_); $new->{'output_fh'} ||= *STDOUT{IO}; $new->accept_targets( 'html', 'HTML' ); $new->accept_targets_as_text( qw(author blockquote comment caution editor epigraph example figure important listing literal note production programlisting screen sidebar table tip warning) ); $new->nix_X_codes(1); $new->nbsp_for_S(1); $new->add_css_tags(0); $new->add_body_tags(0); $new->codes_in_verbatim(1); $new->{'scratch'} = ''; return $new; } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub handle_text { # escape special characters in HTML (<, >, &, etc) $_[0]{'scratch'} .= $_[0]{'in_verbatim'} ? encode_entities( $_[1] ) : $_[1] } sub start_Para { $_[0]{'scratch'} .= '
' } sub start_Verbatim { $_[0]{'scratch'} .= '
'; $_[0]{'in_verbatim'} = 1}
sub start_head0 { $_[0]{'scratch'} = '' }
sub start_head1 { $_[0]{'scratch'} = '' }
sub start_head2 { $_[0]{'scratch'} = '' }
sub start_head3 { $_[0]{'scratch'} = '' }
sub start_head4 { $_[0]{'scratch'} = '' }
sub start_item_bullet { $_[0]{'scratch'} .= '
' }
sub start_item_number { $_[0]{'scratch'} .= " $_[1]{'number'}. " }
sub start_item_text { $_[0]{'scratch'} .= ' ' }
sub start_over_bullet { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub start_over_text { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub start_over_block { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub start_over_number { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_over_bullet { $_[0]{'scratch'} .= '
'; $_[0]->emit('nowrap') }
sub end_over_text { $_[0]{'scratch'} .= '
'; $_[0]->emit('nowrap') }
sub end_over_block { $_[0]{'scratch'} .= '
'; $_[0]->emit('nowrap') }
sub end_over_number { $_[0]{'scratch'} .= ''; $_[0]->emit('nowrap') }
# . . . . . Now the actual formatters:
sub end_Para { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_Verbatim {
$_[0]{'scratch'} .= '
';
$_[0]{'in_verbatim'} = 0;
$_[0]->emit('nowrap');
}
sub end_head0 { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_head1 { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_head2 { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_head3 { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_head4 { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_item_bullet { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_item_number { $_[0]{'scratch'} .= ''; $_[0]->emit() }
sub end_item_text { $_[0]->emit() }
sub start_sidebar {
my ($self, $flags) = @_;
$self->{'scratch'} = $self->{'css_tags'} ? ' ' : ''; $_[0]->emit() }
sub start_figure {
my ($self, $flags) = @_;
$self->{'in_figure'} = 1;
$self->{'figure_title'} = $flags->{'title'} if $flags->{'title'};
}
sub end_figure {
my ($self, $flags) = @_;
$self->{'in_figure'} = 0;
if ($self->{'figure_title'})
{
$self->{'scratch'} .= "" . $self->{'figure_title'} . "
"; delete $self->{'figure_title'}; } $self->emit('nowrap'); } # This handles =begin and =for blocks of all kinds. sub start_for { my ($self, $flags) = @_; if ($self->{'css_tags'}) { $self->{'scratch'} .= 'Table: " . $flags->{'title'} . "
\n"; } $self->{'scratch'} .= '' }
sub end_C { $_[0]{'scratch'} .= '
' }
sub start_E { $_[0]{'scratch'} .= '&' }
sub end_E { $_[0]{'scratch'} .= ';' }
sub start_F { $_[0]{'scratch'} .= ($_[0]{'in_figure'}) ? '