1
0
mirror of https://github.com/bitcoin/bips.git synced 2026-07-13 17:56:00 +00:00

Merge pull request #2209 from jonatack/2026-07-link-check-improvements

script: link check improvements
This commit is contained in:
Murch
2026-07-10 11:13:49 -07:00
committed by GitHub

View File

@@ -4,7 +4,7 @@
# Distributed under the MIT software license, see the accompanying # Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
# #
# Check wrong mediawiki and markdown link formats # Check mediawiki and markdown link formats
ECODE=0 ECODE=0
MEDIAWIKI_ECODE=0 MEDIAWIKI_ECODE=0
@@ -12,7 +12,7 @@ while IFS= read -r fname; do
GRES=$(grep -nE '\]\((https?://|\.\./bip-|/bip-)' "$fname") GRES=$(grep -nE '\]\((https?://|\.\./bip-|/bip-)' "$fname")
if [ "$GRES" != "" ]; then if [ "$GRES" != "" ]; then
if [ $MEDIAWIKI_ECODE -eq 0 ]; then if [ $MEDIAWIKI_ECODE -eq 0 ]; then
>&2 echo "Github Mediawiki format writes links as [URL text], not as [text](URL):" >&2 echo "GitHub Mediawiki format writes links as [URL text], not as [text](URL):"
fi fi
MEDIAWIKI_ECODE=1 MEDIAWIKI_ECODE=1
ECODE=1 ECODE=1
@@ -24,10 +24,10 @@ done < <(find . -type f -name '*.mediawiki' | sort)
MARKDOWN_ECODE=0 MARKDOWN_ECODE=0
while IFS= read -r fname; do while IFS= read -r fname; do
GRES=$(grep -nE '\[[[:space:]]*https?://[^][]*\]|\[\[(\.\./|/)?bip-[^][]*\]\]' "$fname") GRES=$(grep -nE '\[[[:space:]]*https?://[^][[:space:]]+[[:space:]]+[^][]*\]|\[\[https?://[^][]*\]\]|\[\[(\.\./|/)?bip-[^][]*\]\]' "$fname")
if [ "$GRES" != "" ]; then if [ "$GRES" != "" ]; then
if [ $MARKDOWN_ECODE -eq 0 ]; then if [ $MARKDOWN_ECODE -eq 0 ]; then
>&2 echo "Github Markdown format writes links as [text](URL), not as [URL text] or [[URL|text]]:" >&2 echo "GitHub Markdown format writes links as [text](URL), not as [URL text] or [[URL|text]]:"
fi fi
MARKDOWN_ECODE=1 MARKDOWN_ECODE=1
ECODE=1 ECODE=1
@@ -36,4 +36,20 @@ while IFS= read -r fname; do
done <<< "$GRES" done <<< "$GRES"
fi fi
done < <(find . -type f -name '*.md' | sort) done < <(find . -type f -name '*.md' | sort)
REDUNDANT_ECODE=0
while IFS= read -r fname; do
# Matches [url](url)
GRES=$(grep -nE '\[(https?://[^]]+)\]\(\1\)' "$fname")
if [ "$GRES" != "" ]; then
if [ $REDUNDANT_ECODE -eq 0 ]; then
>&2 echo "Markdown links where the text matches the URL are redundant. Use <URL> instead:"
fi
REDUNDANT_ECODE=1
ECODE=1
while IFS= read -r line; do
echo "- ${fname#./}:$line"
done <<< "$GRES"
fi
done < <(find . -type f -name '*.md' | sort)
exit $ECODE exit $ECODE