Skip to content

Fix anchor validation for HTML name attribute (#89)#94

Merged
manuzhang merged 1 commit intomainfrom
fix/html-anchor-name-attribute
Jan 22, 2026
Merged

Fix anchor validation for HTML name attribute (#89)#94
manuzhang merged 1 commit intomainfrom
fix/html-anchor-name-attribute

Conversation

@manuzhang
Copy link
Copy Markdown
Owner

@manuzhang manuzhang commented Jan 22, 2026

This commit fixes issue #89 where anchor validation fails on links like ../file.md#anchors when the anchor is defined using HTML <a name="..."> tags instead of <a id="..."> tags.

Changes:

  • Updated HTML_LINK_PATTERN to match both 'id' and 'name' attributes
  • Changed from greedy to non-greedy matching to handle multiple anchors on the same line
  • Modified contains_anchor() to use re.findall() instead of re.match() to find all anchors on a line
  • Added comprehensive test cases for HTML anchors with both id and name attributes, including anchors in table cells and with dots in names

This commit fixes issue #89 where anchor validation fails on links like
`../file.md#anchors` when the anchor is defined using HTML `<a name="...">`
tags instead of `<a id="...">` tags.

Changes:
- Updated HTML_LINK_PATTERN to match both 'id' and 'name' attributes
- Changed from greedy to non-greedy matching to handle multiple anchors
  on the same line
- Modified contains_anchor() to use re.findall() instead of re.match()
  to find all anchors on a line
- Added comprehensive test cases for HTML anchors with both id and name
  attributes, including anchors in table cells and with dots in names

The fix is backward compatible and handles:
- Legacy <a name="..."> tags (commonly used in tables)
- Modern <a id="..."> tags
- Multiple anchors on a single line (e.g., in table rows)
- Anchors with special characters like dots (e.g., REGISTER.FIELD1)

Fixes #89

Co-Authored-By: Claude <claude@anthropic.com>
@manuzhang manuzhang merged commit 5621b23 into main Jan 22, 2026
24 checks passed
@manuzhang manuzhang deleted the fix/html-anchor-name-attribute branch January 22, 2026 16:58
@manuzhang manuzhang mentioned this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant