2019-08-01 18:06:58 +09:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2019 The Bitcoin Core developers
|
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
#
|
2026-07-07 15:51:30 +08:00
|
|
|
# Check wrong mediawiki and markdown link formats
|
2019-08-01 18:06:58 +09:00
|
|
|
|
|
|
|
|
ECODE=0
|
2026-07-07 15:51:30 +08:00
|
|
|
MEDIAWIKI_ECODE=0
|
2026-06-27 03:25:30 +08:00
|
|
|
while IFS= read -r fname; do
|
|
|
|
|
GRES=$(grep -nE '\]\((https?://|\.\./bip-|/bip-)' "$fname")
|
2024-05-01 18:00:54 -04:00
|
|
|
if [ "$GRES" != "" ]; then
|
2026-07-07 15:51:30 +08:00
|
|
|
if [ $MEDIAWIKI_ECODE -eq 0 ]; then
|
2026-06-27 03:25:30 +08:00
|
|
|
>&2 echo "Github Mediawiki format writes links as [URL text], not as [text](URL):"
|
2019-08-01 18:06:58 +09:00
|
|
|
fi
|
2026-07-07 15:51:30 +08:00
|
|
|
MEDIAWIKI_ECODE=1
|
2024-05-01 18:00:54 -04:00
|
|
|
ECODE=1
|
2026-06-27 03:25:30 +08:00
|
|
|
while IFS= read -r line; do
|
|
|
|
|
echo "- ${fname#./}:$line"
|
|
|
|
|
done <<< "$GRES"
|
2019-08-01 18:06:58 +09:00
|
|
|
fi
|
2026-06-27 03:25:30 +08:00
|
|
|
done < <(find . -type f -name '*.mediawiki' | sort)
|
2026-07-07 15:51:30 +08:00
|
|
|
|
|
|
|
|
MARKDOWN_ECODE=0
|
|
|
|
|
while IFS= read -r fname; do
|
2026-07-10 11:25:25 -06:00
|
|
|
GRES=$(grep -nE '\[[[:space:]]*https?://[^][[:space:]]+[[:space:]]+[^][]*\]|\[\[https?://[^][]*\]\]|\[\[(\.\./|/)?bip-[^][]*\]\]' "$fname")
|
2026-07-07 15:51:30 +08:00
|
|
|
if [ "$GRES" != "" ]; then
|
|
|
|
|
if [ $MARKDOWN_ECODE -eq 0 ]; then
|
|
|
|
|
>&2 echo "Github Markdown format writes links as [text](URL), not as [URL text] or [[URL|text]]:"
|
|
|
|
|
fi
|
|
|
|
|
MARKDOWN_ECODE=1
|
|
|
|
|
ECODE=1
|
|
|
|
|
while IFS= read -r line; do
|
|
|
|
|
echo "- ${fname#./}:$line"
|
|
|
|
|
done <<< "$GRES"
|
|
|
|
|
fi
|
|
|
|
|
done < <(find . -type f -name '*.md' | sort)
|
2019-08-01 18:06:58 +09:00
|
|
|
exit $ECODE
|