Skip to content

Instantly share code, notes, and snippets.

@antoniogamiz
Created July 11, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniogamiz/fbf0a7da9fc145b61df27b36ea5d7ee7 to your computer and use it in GitHub Desktop.
Save antoniogamiz/fbf0a7da9fc145b61df27b36ea5d7ee7 to your computer and use it in GitHub Desktop.
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