Add docs governance and Czech parity updates
This commit is contained in:
45
scripts/check_markdown_links.sh
Executable file
45
scripts/check_markdown_links.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
missing_count=0
|
||||
|
||||
while IFS=$'\t' read -r src link; do
|
||||
case "$link" in
|
||||
''|'#'*|mailto:*|http://*|https://*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
# Remove optional anchors and query strings for filesystem checks.
|
||||
target="${link%%#*}"
|
||||
target="${target%%\?*}"
|
||||
|
||||
[[ -z "$target" ]] && continue
|
||||
|
||||
if [[ "$target" == /* ]]; then
|
||||
# Treat /path as repository-root relative for markdown in GitHub.
|
||||
path="${repo_root}${target}"
|
||||
else
|
||||
path="$(dirname "$src")/$target"
|
||||
fi
|
||||
|
||||
if [[ ! -e "$path" ]]; then
|
||||
printf 'BROKEN: %s -> %s (missing: %s)\n' "$src" "$link" "$path"
|
||||
missing_count=$((missing_count + 1))
|
||||
fi
|
||||
done < <(
|
||||
while IFS= read -r file; do
|
||||
perl -ne 'while(/\[[^\]]*\]\(([^)]+)\)/g){print "$ARGV\t$1\n"}' "$file"
|
||||
done < <(rg --files -g '*.md')
|
||||
)
|
||||
|
||||
if [[ "$missing_count" -gt 0 ]]; then
|
||||
printf '\nFound %d broken markdown link(s).\n' "$missing_count"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Markdown local links: OK"
|
||||
|
||||
Reference in New Issue
Block a user