mdlinkcheck: only look for markdown links in markdown files

It finds debug outputs in source code otherwise.

Output the whitelist "warnings" to stderr to better allow us to count
URLs with `./mdlinkcheck --dry-run | wc -l`.

Closes #19938
This commit is contained in:
Daniel Stenberg
2025-12-11 17:16:37 +01:00
parent 846eaf4e6b
commit 2e3687c60c

View File

@@ -158,9 +158,12 @@ sub findlinks {
open(F, "<:crlf", "$f") ||
return;
# is it a markdown extension?
my $md = ($f =~ /\.md$/i);
while(<F>) {
chomp;
if(/\]\(([^)]*)/) {
if($md && /\]\(([^)]*)/) {
my $link = $1;
#print "$f:$line $link\n";
storelink($f, $line, $link);
@@ -209,7 +212,7 @@ for my $f (@files) {
for my $u (sort keys %whitelist) {
if($whitelist{$u} == 1) {
printf "warning: unused whitelist entry: '$u'\n";
printf STDERR "warning: unused whitelist entry: '$u'\n";
}
}