Skip to content

Commit

Permalink
fix target registering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
finanalyst committed Dec 16, 2023
1 parent 7a5e3f0 commit 9843611
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
>Change log

# 2023-12-16 v4.9.2
* fix bug relating to storing targets, thus not picking up repeated heading names or preserving targets for link checking

# 2023-07-31 v4.9.1
* `P<semantic: XXX>` injects XXX into the Table of Contents at the position in the text.

Expand Down Expand Up @@ -489,4 +492,4 @@ change testing


----
Rendered from CHANGELOG at 2023-07-31T22:03:44Z
Rendered from CHANGELOG at 2023-12-16T12:50:48Z
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Raku::Pod::Render",
"description": "A generic Pod6 Renderer with custom Pod::Blocks, FormatCodes for one or more files using templates, provides HTML and MarkDown.",
"version": "4.9.1",
"version": "4.9.2",
"perl": "6.d",
"authors": [
"Richard Hainsworth"
Expand Down
4 changes: 4 additions & 0 deletions doc/CHANGELOG.rakudoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
=TITLE Raku::Pod::Render
=SUBTITLE Change log

=head1 2023-12-16 v4.9.2
=item fix bug relating to storing targets, thus not picking up repeated heading names
or preserving targets for link checking

=head1 2023-07-31 v4.9.1
=item C<P<semantic: XXX>> injects XXX into the Table of Contents at the position in the text.

Expand Down
10 changes: 7 additions & 3 deletions lib/ProcessedPod.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,19 @@ class ProcessedPod does SetupTemplates {
# the target name used in the link is unique.
# This method uses the default algorithm for HTML and POD
# It may need to be over-ridden, eg., for MarkDown which uses a different targeting function.
# $unique means register target to ensure unique ones

return DEFAULT_TOP if $candidate-name eq DEFAULT_TOP;
# don't rewrite the top

$candidate-name = $candidate-name.subst(/\s+/, '_', :g);
if $unique {
$candidate-name ~= '_1' if $candidate-name $!pod-file.targets;
# will continue to loop until a unique name is found
++$candidate-name while $!pod-file.targets{$candidate-name};
if $!pod-file.targets{$candidate-name} {
$candidate-name ~= '_0' unless $!pod-file.targets{$candidate-name ~ '_0'};
# will continue to loop until a unique name is found
++$candidate-name while $!pod-file.targets{$candidate-name};
}
$!pod-file.targets{$candidate-name}++;
}
$candidate-name
}
Expand Down

0 comments on commit 9843611

Please sign in to comment.