Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for markdown-link-check options #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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