Skip to content

Commit 2684d56

Browse files
author
Sarvesh D
committed
Fixed linking in build_html.pl
Fixes #249 by supporting non-word characters in link names
1 parent 297a21f commit 2684d56

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

build/tools/build_html.pl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,25 @@
1313
my @chapters = get_chapter_list();
1414
my $anchors = get_anchors(@chapters);
1515

16+
# start position of a link in the scratchpad
17+
my $link_pos;
18+
19+
sub Pod::PseudoPod::HTML::start_L
20+
{
21+
my $self = shift;
22+
$link_pos = length($self->{scratch});
23+
}
24+
1625
sub Pod::PseudoPod::HTML::end_L
1726
{
1827
my $self = shift;
19-
if ($self->{scratch} =~ s/\b(\w+)$//)
20-
{
21-
my $link = $1;
22-
die "Unknown link $link\n" unless exists $anchors->{$link};
23-
$self->{scratch} .= '<a href="' . $anchors->{$link}[0] . "#$link\">"
24-
. $anchors->{$link}[1] . '</a>';
25-
}
28+
my $link = substr($self->{scratch}, $link_pos);
29+
30+
die "Unknown link $link\n" unless exists $anchors->{$link};
31+
32+
substr($self->{scratch}, $link_pos, length($link),
33+
'<a href="' . $anchors->{$link}[0] . "#$link\">"
34+
. $anchors->{$link}[1] . '</a>');
2635
}
2736

2837
for my $chapter (@chapters)

0 commit comments

Comments
 (0)