_ilink_re = re.compile(r'\[[^\]]+\]\(([^)]+)\)', flags=re.M)
_elink_re = re.compile(r'<a(?:\s+[^>]+|\s*)>')
+_name_re = re.compile(r'name="([^"]+)"')
_href_re = re.compile(r'href="([^"]+)"')
_classes_re = re.compile(r'class="([^"]+)"')
for link in elinks:
href = _href_re.search(link)
+ name = _name_re.search(link)
classes = _classes_re.search(link)
+ if name and not href:
+ # simple anchor
+ continue
+
if classes is None:
_pwarn(path, 'External link has no "ext" class: "{}"'.format(link))
classes = []
href = href.group(1)
if href.startswith('#') and 'int' not in classes:
- _pwarn(path, 'External link starts with #: "{}"'.format(href.group(1)))
+ _pwarn(path, 'External link starts with #: "{}"'.format(href))
if 'int' in classes:
ilinks.append(href)
continue
section_info.add_out_link(_ExtLink(href))
- else:
- _perror(path, 'External link with no "href" attribute: "{}"'.format(link))
+ elif not name:
+ _perror(path, 'External link with no "href" or "name" attribute: "{}"'.format(link))
ret = False
for link in ilinks: