#============================================================= -*-Perl-*- # # Pod::POM::View::HTML # # DESCRIPTION # HTML view of a Pod Object Model. # # AUTHOR # Andy Wardley # # COPYRIGHT # Copyright (C) 2000 Andy Wardley. All Rights Reserved. # # This module is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # REVISION # $Id: HTML.pm,v 1.6 2002/03/18 07:47:36 stas Exp $ # #======================================================================== package Pod::POM::View::HTML; require 5.004; use strict; use Pod::POM::View; use base qw( Pod::POM::View ); use vars qw( $VERSION $DEBUG $ERROR $AUTOLOAD ); use Text::Wrap; $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); $DEBUG = 0 unless defined $DEBUG; my $HTML_PROTECT = 0; my @OVER; sub new { my $class = shift; my $self = $class->SUPER::new(@_) || return; # initalise stack for maintaining info for nested lists $self->{ OVER } = []; return $self; } sub view { my ($self, $type, $item) = @_; if ($type =~ s/^seq_//) { return $item; } elsif (UNIVERSAL::isa($item, 'HASH')) { if (defined $item->{ content }) { return $item->{ content }->present($self); } elsif (defined $item->{ text }) { my $text = $item->{ text }; return ref $text ? $text->present($self) : $text; } else { return ''; } } elsif (! ref $item) { return $item; } else { return ''; } } sub view_pod { my ($self, $pod) = @_; return "\n" . $pod->content->present($self) . "\n"; } sub view_head1 { my ($self, $head1) = @_; my $title = $head1->title->present($self); return "

$title

\n\n" . $head1->content->present($self); } sub view_head2 { my ($self, $head2) = @_; my $title = $head2->title->present($self); return "

$title

\n" . $head2->content->present($self); } sub view_head3 { my ($self, $head3) = @_; my $title = $head3->title->present($self); return "

$title

\n" . $head3->content->present($self); } sub view_head4 { my ($self, $head4) = @_; my $title = $head4->title->present($self); return "

$title

\n" . $head4->content->present($self); } sub view_over { my ($self, $over) = @_; my ($start, $end, $strip); my $items = $over->item(); return "" unless @$items; my $first_title = $items->[0]->title(); if ($first_title =~ /^\s*\*\s*/) { # '=item *' =>