Skip to content

Commit

Permalink
Fixed linking in build_html.pl
Browse files Browse the repository at this point in the history
Fixes #249 by supporting non-word characters in link names
  • Loading branch information
Sarvesh D committed Oct 24, 2015
1 parent 297a21f commit 2684d56
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions build/tools/build_html.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@
my @chapters = get_chapter_list();
my $anchors = get_anchors(@chapters);

# start position of a link in the scratchpad
my $link_pos;

sub Pod::PseudoPod::HTML::start_L
{
my $self = shift;
$link_pos = length($self->{scratch});
}

sub Pod::PseudoPod::HTML::end_L
{
my $self = shift;
if ($self->{scratch} =~ s/\b(\w+)$//)
{
my $link = $1;
die "Unknown link $link\n" unless exists $anchors->{$link};
$self->{scratch} .= '<a href="' . $anchors->{$link}[0] . "#$link\">"
. $anchors->{$link}[1] . '</a>';
}
my $link = substr($self->{scratch}, $link_pos);

die "Unknown link $link\n" unless exists $anchors->{$link};

substr($self->{scratch}, $link_pos, length($link),
'<a href="' . $anchors->{$link}[0] . "#$link\">"
. $anchors->{$link}[1] . '</a>');
}

for my $chapter (@chapters)
Expand Down

0 comments on commit 2684d56

Please sign in to comment.