Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: anchor link checks support HTML tags like <a name="foo"></a> #331

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dklimpel
Copy link
Contributor

@dklimpel dklimpel commented Jun 2, 2024

Extracts all html tags with the attribute id and all a tags with the attribute name and allows them as valid section links.

Ignore:

  • code blocks (```)
  • single code (`)
  • html comments

Fits the lint rule MD51

Alternatively, any HTML tag with an id attribute or an a tag with a name attribute can be used to define a fragment

fixes:

related to:

@MikeMcC399
Copy link

@dklimpel

[Item 1](#item-one)
[Item 2](#item-two)

<a id="item-one">Item 1 target</a>
<a id='item-two'>Item 2 target</a>

resulted in

$ npx markdown-link-check anchor-in-html-test.md

FILE: anchor-in-html-test.md
  [✓] #item-one
  [✖] #item-two

  2 links checked.

  ERROR: 1 dead links found!
  [✖] #item-two → Status: 404

using
markdown-link-check@3.12.2 (git+ssh://git@github.com/dklimpel/markdown-link-check.git#cb1cb610ac08ba78d9f8735402929722d7253088)

Would you expect single quotes to work as well as the double quotes?

@dklimpel
Copy link
Contributor Author

dklimpel commented Jun 3, 2024

Would you expect single quotes to work as well as the double quotes?

Single quotes were not yet in the scope.

@MikeMcC399
Copy link

@dklimpel

Single quotes were not yet in the scope.

Do you plan to add them in this PR? It may be confusing to have only double quotes working if this PR is merged as is.

@dklimpel
Copy link
Contributor Author

dklimpel commented Jun 3, 2024

I have added a new commit for supporting single quotes.

@MikeMcC399
Copy link

@dklimpel

Great work! I confirm it works!

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.

None yet

2 participants