+ # Make sure every link has a section.
+ while ( $contents =~ /$markup_re/msg ) {
+ my $target = $1;
+ next unless $target =~ /^L<(.*)>$/; # Skip if not L<...>
+ $target = $1; # Peal away L< and >
+ $target =~ s/\/[^\/]*$//; # Peal away possible anchor
+ $target =~ s/.*\|//g; # Peal away possible link text
+ next if $target eq ''; # Skip if links within page, or
+ next if $target =~ /::/; # links to a Perl module, or
+ next if $target =~ /^https?:/; # is a URL link, or
+ next if $target =~ /\([1357]\)$/; # it has a section
+ err($id, "Section missing in $target")
+ }
+ # Check for proper links to commands.
+ while ( $contents =~ /L<([^>]*)\(1\)(?:\/.*)?>/g ) {
+ my $target = $1;
+ next if $target =~ /openssl-?/;
+ next if -f "doc/man1/$target.pod";
+ # TODO: Filter out "foreign manual" links.
+ next if $target =~ /ps|apropos|sha1sum|procmail|perl/;
+ err($id, "Bad command link L<$target(1)>");
+ }
+ # Check for proper in-man-3 API links.
+ while ( $contents =~ /L<([^>]*)\(3\)(?:\/.*)?>/g ) {
+ my $target = $1;
+ err($id, "Bad L<$target>")
+ unless $target =~ /^[_[:alpha:]][_[:alnum:]]*$/
+ }
+