-
Notifications
You must be signed in to change notification settings - Fork 18
Anchors in attr_list contains other attribute value are reported as invalid urls #42
Copy link
Copy link
Closed
Description
Describe the bug
For example, the following header is reported as invalid url.
## Header {: #header-anchor .class-name }anchor_slug: header-anchor-class-name
https://github.com/manuzhang/mkdocs-htmlproofer-plugin/blob/main/htmlproofer/plugin.py#L154
@staticmethod
def contains_anchor(markdown: str, anchor: str) -> bool:
"""Check if a set of Markdown source text contains a heading that corresponds to a
given anchor."""
for line in markdown.splitlines():
# Markdown allows whitespace before headers and an arbitrary number of #'s.
heading_match = HEADING_PATTERN.match(line)
if heading_match is not None:
heading = heading_match.groups()[0]
# Headings are allowed to have images after them, of the form:
# # Heading [] or ![Image][image-reference]
# But these images are not included in the generated anchor, so remove them.
heading = re.sub(IMAGE_PATTERN, '', heading)
anchor_slug = slugify(heading, '-')
if anchor == anchor_slug:
return True
link_match = HTML_LINK_PATTERN.match(line)
if link_match is not None and link_match.group(1) == anchor:
return True
return Falsemkdocs.yml
markdown_extensions:
- attr_list
plugins:
- htmlprooferWould it be possible to support attr_list extensions format?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels