🐛 fix(tests): make doc link check awk-portable

This commit is contained in:
csh 2026-01-08 15:44:39 +08:00
parent 6244aa39da
commit 07583c8283
1 changed files with 10 additions and 4 deletions

View File

@ -100,13 +100,19 @@ extract_links() {
gsub(/`[^`]*`/, "", line)
while (match(line, /\[[^]]+\]\(([^)]+)\)/, m)) {
print NR "\t" m[1]
while (match(line, /\[[^]]+\]\([^)]*\)/)) {
link = substr(line, RSTART, RLENGTH)
sub(/^\[[^]]+\]\(/, "", link)
sub(/\)$/, "", link)
print NR "\t" link
line = substr(line, RSTART + RLENGTH)
}
if (match(line, /^\[[^]]+\]:[[:space:]]*(.+)/, ref)) {
print NR "\t" ref[1]
if (match(line, /^\[[^]]+\]:[[:space:]]*[^[:space:]]+/)) {
link = substr(line, RSTART, RLENGTH)
sub(/^\[[^]]+\]:[[:space:]]*/, "", link)
sub(/[[:space:]].*$/, "", link)
print NR "\t" link
}
}
' "$1"