Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions hooks/mdlink-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ if ! command -v markdown-link-check; then
exit 1
fi

# Parse arguments and separate files from markdown-link-check options
ARGS=()
FILES=()
while [[ $# -gt 0 ]]; do case "$1" in
-c | --config | -a | --alive | -r | --retry) ARGS+=("$1" "$2"); shift; ;;
-p | --progress | -q | --quiet | -v | --verbose) ARGS+=("$1"); ;;
*) FILES+=("$1"); ;;
esac; shift; done;


# This is the recommended way to set the project root for properly resolving absolute paths. See
# https://github.com/tcort/markdown-link-check/issues/16 for more info.
# markdown-link-check 3.10 introduced checking anchors, which does not work witihn the same file. See
Expand All @@ -34,6 +44,7 @@ cat > "$TMP_CONFIG" <<EOF
}
EOF

for file in "$@"; do
markdown-link-check -c "$TMP_CONFIG" "$file"
for file in "${FILES[@]}"; do
# shellcheck disable=SC2068
markdown-link-check -c "$TMP_CONFIG" ${ARGS[@]} "$file"
done