diff --git a/src/tools/EPICS/PodHtml.pm b/src/tools/EPICS/PodHtml.pm index ccfbe4729..785372159 100644 --- a/src/tools/EPICS/PodHtml.pm +++ b/src/tools/EPICS/PodHtml.pm @@ -5,6 +5,20 @@ use warnings; use base 'Pod::Simple::HTML'; +sub encode_entities { + my ($self, $str) = @_; + my %entities = ( + q{>} => 'gt', + q{<} => 'lt', + q{'} => '#39', + q{"} => 'quot', + q{&} => 'amp' + ); + my $ents = join '', keys %entities; + $str =~ s/([$ents])/'&' . $entities{$1} . ';'/ge; + return $str; +} + # Translate L # into link text @@ -18,9 +32,11 @@ sub do_pod_link { if ($link->tagname eq 'L' and $link->attr('type') eq 'pod') { my $to = $link->attr('to'); my $section = $link->attr('section'); + $section = $self->section_escape($section) + if defined $section and length($section .= ''); # (stringify) - $ret = $to ? "$to.html" : ''; - $ret .= "#$section" if $section; + $ret = (defined $to and length $to) ? "$to.html" : ''; + $ret .= "#$section" if defined $section and length $section; } else { # all other links are generated by the parent class diff --git a/src/tools/EPICS/PodXHtml.pm b/src/tools/EPICS/PodXHtml.pm index d922c0645..d39212988 100644 --- a/src/tools/EPICS/PodXHtml.pm +++ b/src/tools/EPICS/PodXHtml.pm @@ -5,15 +5,34 @@ use warnings; use base 'Pod::Simple::XHTML'; +BEGIN { + if ($Pod::Simple::XHTML::VERSION < '3.16') { + # encode_entities() wasn't a method, add it + our *encode_entities = sub { + my ($self, $str) = @_; + my %entities = ( + q{>} => 'gt', + q{<} => 'lt', + q{'} => '#39', + q{"} => 'quot', + q{&} => 'amp' + ); + my $ents = join '', keys %entities; + $str =~ s/([$ents])/'&' . $entities{$1} . ';'/ge; + return $str; + } + } +} + # Translate L # into link text sub resolve_pod_page_link { my ($self, $to, $section) = @_; - my $ret = $to ? "$to.html" : ''; + my $ret = defined $to ? "$to.html" : ''; $ret .= '#' . $self->idify($self->encode_entities($section), 1) - if $section; + if defined $section; return $ret; } diff --git a/src/tools/dbdToHtml.pl b/src/tools/dbdToHtml.pl index afbb0a601..0bfeb19a3 100644 --- a/src/tools/dbdToHtml.pl +++ b/src/tools/dbdToHtml.pl @@ -19,26 +19,9 @@ use EPICS::Readfile; BEGIN { $::XHTML = eval "require EPICS::PodXHtml; 1"; - $::ENTITIES = eval "require HTML::Entities; 1"; if (!$::XHTML) { require EPICS::PodHtml; } - if (!$::ENTITIES) { - my %entities = ( - q{>} => 'gt', - q{<} => 'lt', - q{'} => '#39', - q{"} => 'quot', - q{&} => 'amp', - ); - - sub encode_entities { - my $str = shift; - my $ents = join '', keys %entities; - $str =~ s/([ $ents ])/'&' . ($entities{$1} || sprintf '#x%X', ord $1) . ';'/xge; - return $str; - } - } } use Pod::Usage; @@ -190,7 +173,7 @@ my $pod = join "\n", '=for html
', '', } $dbd->pod, '=for html
', ''; -$podHtml->force_title(encode_entities($title)); +$podHtml->force_title($podHtml->encode_entities($title)); $podHtml->perldoc_url_prefix(''); $podHtml->perldoc_url_postfix('.html'); $podHtml->output_fh($out);