Files
epics-base/src/tools/EPICS/PodXHtml.pm
Andrew Johnson e4ebc01401
Some checks failed
Base / Ub-22 clang C++11 (push) Has been cancelled
Base / Ub-22 clang (push) Has been cancelled
Base / Ub-22 gcc + RT-4.9 (push) Has been cancelled
Base / MacOS clang (push) Has been cancelled
Base / Ub-24 gcc-13 c++20 Werror (push) Has been cancelled
Base / Ub-22 gcc + RT-5.1 beatnik (push) Has been cancelled
Base / Ub-22 gcc + RT-4.10 (push) Has been cancelled
Base / Ub-22 gcc + RT-5.1 pc686 (push) Has been cancelled
Base / Ub-22 gcc + RT-5.1 uC5282 (push) Has been cancelled
Base / Ub-22 gcc unsigned char (push) Has been cancelled
Base / Ub-22 gcc + MinGW, static (push) Has been cancelled
Base / Win2019 MSC-19 (push) Has been cancelled
Base / Win2019 MSC-19, debug (push) Has been cancelled
Base / Win2019 MSC-19, static (push) Has been cancelled
Base / Ub-22 gcc + RT-5.1 xilinx_zynq_a9_qemu (push) Has been cancelled
Base / Win2019 mingw (push) Has been cancelled
Base / Ub-22 gcc + MinGW (push) Has been cancelled
Base / Ub-22 gcc C++11, static (push) Has been cancelled
Check EditorConfig / editorconfig (push) Failing after 1s
Base / Cross linux-aarch64 (push) Failing after 2s
Base / Cross linux-arm gnueabi (push) Failing after 1s
Base / Cross linux-arm gnueabihf (push) Failing after 2s
Base / CentOS-8 (push) Failing after 2s
Base / Fedora-33 (push) Failing after 5s
Base / Fedora-latest (push) Failing after 4s
Base / Rocky-9 (push) Failing after 5s
CodeQL / Analyze (cpp) (push) Failing after 1s
Base / Docker CentOS-7 (push) Failing after 14s
Fix EPICS::PodXHtml and generate section links
Overrides an internal method in Pod::Simple::XHTML that
appends a section sign which links to this section.
2025-03-19 11:26:51 -05:00

60 lines
1.5 KiB
Perl

package EPICS::PodXHtml;
use strict;
use warnings;
use base 'Pod::Simple::XHTML';
BEGIN {
if ($Pod::Simple::XHTML::VERSION < '3.16') {
# Add encode_entities() as a method
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<link text|filename/Section name>
# into <a href="filename.html#Section-name">link text</a>
sub resolve_pod_page_link {
my ($self, $to, $section) = @_;
my $ret = defined $to ? "$to.html" : '';
$ret .= '#' . $self->idify($self->encode_entities($section), 1)
if defined $section;
return $ret;
}
sub _end_head {
my $h = delete $_[0]{in_head};
my $add = $_[0]->html_h_level;
$add = 1 unless defined $add;
$h += $add - 1;
my $id = $_[0]->idify($_[0]{htext});
my $text = $_[0]{scratch};
my $hid = qq{<h$h id="$id">};
my $link = qq{ <a class='sect' href="#$id">&sect;</a>};
$_[0]{'scratch'} = $_[0]->backlink && ($h - $add == 0)
# backlinks enabled && =head1
? qq{$hid<a href="#_podtop_">$text</a> $link</h$h>}
: qq{$hid$text $link</h$h>};
$_[0]->emit;
push @{ $_[0]{'to_index'} }, [$h, $id, delete $_[0]{'htext'}];
}
1;