Skip to content

Commit fb32bd0

Browse files
committed
Fix #407 again with less duplication
1 parent e0099d0 commit fb32bd0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

htmlify.p6

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ sub find-references(:$pod!, :$url, :$origin) {
340340
}
341341

342342
sub find-p5to6-functions(:$pod!, :$url, :$origin) {
343-
if $pod ~~ Pod::Item {
343+
if $pod ~~ Pod::Heading && $pod.level == 2 {
344+
# Add =head2 function names to hash
344345
my $func-name = ~$pod.contents[0].contents;
345346
%p5to6-functions{$func-name} = 1;
346347
}
@@ -641,10 +642,15 @@ sub write-search-file () {
641642
}", value: "$name", url: "{@docs.[0].url}" \}]] #"
642643
}
643644
}).flat;
645+
646+
# Add p5to6 functions to JavaScript search index
644647
@items.append( %p5to6-functions.keys.map( {
645-
my $url = "/language/5to6-perlfunc#" ~ uri_escape($_);
646-
sprintf( q[[{ category: "5to6-perlfunc", value: "%s", url: "%s" }]], $_, $url);
647-
}) );
648+
my $url = "/language/5to6-perlfunc#" ~ $_.subst(' ', '_', :g);
649+
sprintf(
650+
q[[{ category: "5to6-perlfunc", value: "%s", url: "%s" }]],
651+
$_, $url
652+
);
653+
}));
648654
spurt("html/js/search.js", $template.subst("ITEMS", @items.join(",\n") ));
649655
}
650656

0 commit comments

Comments
 (0)