From 0c53f82635b053994dbaf1ef8bf6ac18d0a60808 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Mon, 18 Oct 2021 18:16:45 -0700 Subject: [PATCH] Some hacks on top of an upstream example script I found. --- verify-markdown-links.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/verify-markdown-links.py b/verify-markdown-links.py index 3da50d2..351d929 100755 --- a/verify-markdown-links.py +++ b/verify-markdown-links.py @@ -29,11 +29,13 @@ for (text, link) in find_md_links(body_markdown): errMsg = None if not re.match(r'^(mailto|http|ftp|#)', link, re.IGNORECASE): path = Path(link) - if not path.is_file(): + if not path.is_file() and not path.is_dir(): errMsg = "local file by that name does not exist for relative file link" + else: + print(path) # FIXME: test other types of links if errMsg: - print("Bad link of \"%s\" (labeled as \"%s\") has error: %s" % (link, text, errMsg)) + print("# Bad link of \"%s\" (labeled as \"%s\") has error: %s" % (link, text, errMsg)) exit(0) # Below doesn't work, didn't have time to find out why