diff options
Diffstat (limited to 'cpan/Pod-Simple/lib/Pod/Simple/XHTML.pm')
-rw-r--r-- | cpan/Pod-Simple/lib/Pod/Simple/XHTML.pm | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/cpan/Pod-Simple/lib/Pod/Simple/XHTML.pm b/cpan/Pod-Simple/lib/Pod/Simple/XHTML.pm index df896e64a7..3a2d2094c6 100644 --- a/cpan/Pod-Simple/lib/Pod/Simple/XHTML.pm +++ b/cpan/Pod-Simple/lib/Pod/Simple/XHTML.pm @@ -45,7 +45,7 @@ declare the output character set as UTF-8 before parsing, like so: package Pod::Simple::XHTML; use strict; use vars qw( $VERSION @ISA $HAS_HTML_ENTITIES ); -$VERSION = '3.28'; +$VERSION = '3.29'; use Pod::Simple::Methody (); @ISA = ('Pod::Simple::Methody'); @@ -132,7 +132,7 @@ A document type tag for the file. This option is not set by default. =head2 html_charset -The charater set to declare in the Content-Type meta tag created by default +The character set to declare in the Content-Type meta tag created by default for C<html_header_tags>. Note that this option will be ignored if the value of C<html_header_tags> is changed. Defaults to "ISO-8859-1". @@ -313,9 +313,9 @@ The base implementation just escapes the text. The callback methods C<start_code> and C<end_code> emits the C<code> tags before and after C<handle_code> is invoked, so you might want to override these -together with C<handle_code> if this wrapping isn't suiteable. +together with C<handle_code> if this wrapping isn't suitable. -Note that the code might be broken into mulitple segments if there are +Note that the code might be broken into multiple segments if there are nested formatting codes inside a C<< CE<lt>...> >> sequence. In between the calls to C<handle_code> other markup tags might have been emitted in that case. The same is true for verbatim sections if the C<codes_in_verbatim> @@ -352,7 +352,23 @@ sub handle_text { # literal xhtml region, since handle_code calls encode_entities. $_[0]->handle_code( $_[1], $_[0]{'in_code'}[-1] ); } else { - $_[0]{'scratch'} .= $text; + if ($_[0]->{in_for}) { + my $newlines = $_[0]->__in_literal_xhtml_region ? "\n\n" : ''; + if ($_[0]->{started_for}) { + if ($text =~ /\S/) { + delete $_[0]->{started_for}; + $_[0]{'scratch'} .= $text . $newlines; + } + # Otherwise, append nothing until we have something to append. + } else { + # The parser sometimes preserves newlines and sometimes doesn't! + $text =~ s/\n\z//; + $_[0]{'scratch'} .= $text . $newlines; + } + } else { + # Just plain text. + $_[0]{'scratch'} .= $text; + } } $_[0]{htext} .= $text if $_[0]{'in_head'}; @@ -371,7 +387,7 @@ sub handle_code { } sub start_Para { - $_[0]{'scratch'} = '<p>'; + $_[0]{'scratch'} .= '<p>'; } sub start_Verbatim { @@ -496,20 +512,27 @@ sub start_for { my ($self, $flags) = @_; push @{ $self->{__region_targets} }, $flags->{target_matching}; + $self->{started_for} = 1; + $self->{in_for} = 1; unless ($self->__in_literal_xhtml_region) { $self->{scratch} .= '<div'; $self->{scratch} .= qq( class="$flags->{target}") if $flags->{target}; - $self->{scratch} .= '>'; + $self->{scratch} .= ">\n\n"; } - - $self->emit; - } + sub end_for { my ($self) = @_; + delete $self->{started_for}; + delete $self->{in_for}; - $self->{'scratch'} .= '</div>' unless $self->__in_literal_xhtml_region; + if ($self->__in_literal_xhtml_region) { + # Remove trailine newlines. + $self->{'scratch'} =~ s/\s+\z//s; + } else { + $self->{'scratch'} .= '</div>'; + } pop @{ $self->{__region_targets} }; $self->emit; @@ -526,16 +549,17 @@ sub start_Document { $title = $self->force_title || $self->title || $self->default_title || ''; $metatags = $self->html_header_tags || ''; if (my $css = $self->html_css) { - $metatags .= $css; if ($css !~ /<link/) { # this is required to be compatible with Pod::Simple::BatchHTML $metatags .= '<link rel="stylesheet" href="' . $self->encode_entities($css) . '" type="text/css" />'; + } else { + $metatags .= $css; } } if ($self->html_javascript) { $metatags .= qq{\n<script type="text/javascript" src="} . - $self->html_javascript . "'></script>"; + $self->html_javascript . '"></script>'; } $bodyid = $self->backlink ? ' id="_podtop_"' : ''; $self->{'scratch'} .= <<"HTML"; |