Files
BlueArchiveToolkit/scripts/check-doc-links.sh
T
nyaKazuha d21c01a697
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s
docs: 校正文档分类与当前边界
2026-09-04 19:58:07 +08:00

43 lines
942 B
Bash

#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${repo_root}"
missing=0
while IFS= read -r -d '' file; do
while IFS= read -r link; do
target="${link#*](}"
target="${target%)}"
target="${target%%#*}"
target="${target%% *}"
target="${target#<}"
target="${target%>}"
case "${target}" in
''|\#|http://*|https://*|mailto:*)
continue
;;
esac
resolved="$(dirname "${file}")/${target}"
if [[ ! -e "${resolved}" ]]; then
printf 'missing Markdown link: %s: %s -> %s\n' \
"${file}" "${target}" "${resolved}" >&2
missing=1
fi
done < <(rg -o '\]\([^)]*\)' "${file}" || true)
done < <(
find . -type f \( -name '*.md' -o -name '*.markdown' \) \
-not -path './.git/*' \
-not -path './target/*' \
-print0
)
if [[ "${missing}" -ne 0 ]]; then
exit 1
fi
printf 'markdown local link check ok\n'