|
@@ -48,14 +48,20 @@ def getBrokenLinks(filepath):
|
|
|
finally:
|
|
|
f.close()
|
|
|
|
|
|
- regexLink = re.compile('\[(.*?)\]\((?P<links>(.*?))\)')
|
|
|
+ linkRegexLink = re.compile('\[(.*?)\]\((?P<link>(.*?))\)')
|
|
|
+ referenceLinkRegex = re.compile('^\s{0,3}\[.*?\]:\s*(?P<link>[^<\s]+|<[^<>\r\n]+>)')
|
|
|
links = []
|
|
|
for line in lines:
|
|
|
- matchLinks = regexLink.search(line)
|
|
|
+ matchLinks = linkRegexLink.search(line)
|
|
|
+ matchReferenceLinks = referenceLinkRegex.search(line)
|
|
|
if matchLinks:
|
|
|
- relativeLink = matchLinks.group('links')
|
|
|
+ relativeLink = matchLinks.group('link')
|
|
|
if not str(relativeLink).startswith('http'):
|
|
|
links.append(relativeLink)
|
|
|
+ if matchReferenceLinks:
|
|
|
+ referenceLink = matchReferenceLinks.group('link').strip('<>')
|
|
|
+ if not str(referenceLink).startswith('http'):
|
|
|
+ links.append(referenceLink)
|
|
|
|
|
|
for link in links:
|
|
|
sections = link.split('#')
|