Created
July 11, 2019 09:54
-
-
Save antoniogamiz/fbf0a7da9fc145b61df27b36ea5d7ee7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub find-references(:$pod, :$url, :$origin, :@refs = []) is export { | |
if $pod ~~ Pod::FormattingCode && $pod.type eq 'X' { | |
my $index-name-attr = ""; | |
my $index-text = recurse-until-str($pod).join; | |
my @indices = $pod.meta; | |
$index-name-attr = qq[index-entry{@indices ?? '-' !! ''}{@indices.join('-')}{$index-text ?? '-' !! ''}$index-text] | |
.subst('_', '__', :g).subst(' ', '_', :g).subst('%', '%25', :g).subst('#', '%23', :g); | |
@refs.push: create-references(:$pod, :$origin, url => $url ~ '#' ~ $index-name-attr).Slip; | |
} | |
elsif $pod.?contents { | |
for $pod.contents -> $sub-pod { | |
find-references(:pod($sub-pod), :$url, :$origin, :@refs) if $sub-pod ~~ Pod::Block; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment