mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 12:45:17 +08:00
docs: 校正文档分类与当前边界
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#!/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'
|
||||
Reference in New Issue
Block a user