Some hacks on top of an upstream example script I found.

This commit is contained in:
Bradley M. Kuhn 2021-10-18 18:16:45 -07:00
parent 9940de3bde
commit 0c53f82635

View file

@ -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