markdown-link-check icon indicating copy to clipboard operation
markdown-link-check copied to clipboard

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

Open dklimpel opened this issue 1 year ago • 5 comments

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:

  • #202
  • #195

related to:

  • #328

dklimpel avatar Jun 02 '24 13:06 dklimpel

@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 [email protected] (git+ssh://[email protected]/dklimpel/markdown-link-check.git#cb1cb610ac08ba78d9f8735402929722d7253088)

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

MikeMcC399 avatar Jun 03 '24 12:06 MikeMcC399

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

Single quotes were not yet in the scope.

dklimpel avatar Jun 03 '24 13:06 dklimpel

@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.

MikeMcC399 avatar Jun 03 '24 13:06 MikeMcC399

I have added a new commit for supporting single quotes.

dklimpel avatar Jun 03 '24 14:06 dklimpel

@dklimpel

Great work! I confirm it works!

MikeMcC399 avatar Jun 03 '24 14:06 MikeMcC399

It would be really great to have this. Having a similar issue when adding HTML links to markdown table cells like <a id="android-os-api-level" href="#android-os-api-level">android.os.api_level</a> and the check is failing now.

joaopgrassi avatar Oct 17 '24 11:10 joaopgrassi

@tcort I have resolved the conflicts.

dklimpel avatar Nov 05 '24 12:11 dklimpel