docs: improve relative link linting and fix broken (#26020)
This commit is contained in:
parent
042ebdd5b0
commit
e6f570d191
6 changed files with 14 additions and 8 deletions
|
@ -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('#')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue