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

Parse HTML in order to find anchors (like #tomato) in the same document #195

Open
sschuberth opened this issue Apr 19, 2022 · 15 comments
Open

Comments

@sschuberth
Copy link

markdown-link-check doesn't parse HTML, so it can't find #tomato in your test, but it is something I'm planning on adding.

Originally posted by @tcort in #193 (comment)

This was referenced Apr 19, 2022
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Apr 19, 2022
Revert this once [1] is fixed.

[1]: tcort/markdown-link-check#195

Signed-off-by: Sebastian Schuberth <[email protected]>
tsteenbe pushed a commit to oss-review-toolkit/ort that referenced this issue Apr 19, 2022
Revert this once [1] is fixed.

[1]: tcort/markdown-link-check#195

Signed-off-by: Sebastian Schuberth <[email protected]>
@MikeMcC399
Copy link

MikeMcC399 commented Jun 13, 2022

This would be nice to have back again. It used to work in 3.8.7 and no longer works in 3.9.3 or 3.10.3.

@Shocktrooper
Copy link

Hello! Was curious about the status of this because anchor links are valid markdown but they are all currently broken when checking if links are valid

@MikeMcC399
Copy link

MikeMcC399 commented Nov 4, 2022

@Shocktrooper
This issue is about anchor links defined in HTML. Is that the same issue that you have?

Steps to reproduce failure

195.md file contains:

- [Open Issues](#issue_list) 
<a name='issue_list'>Open Issues</a>
npm install [email protected]
npx markdown-link-check ./195.md

FILE: ./195.md
[✓] #issue_list

1 links checked.

Now update to latest version:

npm install [email protected]
npx markdown-link-check ./195.md

FILE: ./195.md
  [✖] #issue_list

  1 links checked.

  ERROR: 1 dead links found!
  [✖] #issue_list → Status: 404

Steps to reproduce correct checking of anchor links

If the anchor link is defined through Markdown (no use of HTML in Markdown file), then the check works:

[link to issues](#issue-list)
# issue list
FILE: ./195-b.md
  [✓] #issue-list

  1 links checked.

@Shocktrooper
Copy link

Oh my apologies my issue is plain anchor links in markdown. Not html

@MikeMcC399
Copy link

@Shocktrooper

... my issue is plain anchor links in markdown. Not html

Perhaps you could give an example of a failing test? Also which version of markdown-link-check are you using? Does my example give an error or does it work for you?

[link to issues](#issue-list)
# issue list

@MikeMcC399
Copy link

I am still stuck with using "markdown-link-check": "~3.8.7" due to this regression. Is there any chance of getting it fixed in 3.10.* or later?

@Shocktrooper
Copy link

@MikeMcC399 It appears that I had an issue with my syntax that was not apparent and it is not an issue with the tool

@srl295
Copy link

srl295 commented Dec 13, 2022

@Shocktrooper would you be able to give an example of what the syntax issue was and how it was fixed? just in case that's what i or others are running into.

@Shocktrooper
Copy link

for ## Architecture-Diagram

[Architecture Diagram](#_Architecture_Diagram)
was changed to
[Architecture Diagram](#architecture-diagram)

and for ## Access and authentication

[Authentication](#_Authentication)
was changed to
[Authentication](#access-and-authentication)

The first example was an old and valid way that anchor links worked in an older version of markdown and the second example was just a rename someone forgot I believe

@jhvhs
Copy link

jhvhs commented Feb 21, 2023

@MikeMcC399 Sorry to revive an old conversation, but just to be clear, versions 3.8 and prior reported "success" on internal anchor links, but the fact is, it was an unproven positive. Try to change the fragment to any gibberish, and it will pass with flying colours. The solution I see at the moment, until the issue is fixed, is to ignore URLs that consist entirely of fragments. This way they will remain explicitly unchecked, showing up in the report as ignored.

@MikeMcC399
Copy link

MikeMcC399 commented Feb 21, 2023

@jhvhs
No need to apologize for responding to an open issue, however old it is!

Shockingly you are correct!

3.8.7

A bad anchor link is not detected in 3.8.7. All pass.

3.11.0

In version 3.11.0 an anchor link ...

  • which is not embedded in HTML passes. - correct
  • which is embedded in HTML fails. - subject of this issue. Would expect to pass but it fails.
  • to a non existent target fails. - correct

Test set

Tested with:

| Link source                 | Should | 3.8.7    | 3.11.0   |
| --------------------------- | ------ | -------- | -------- |
| [Good regular link](#link1) | Pass   | Pass     | Pass     |
| [Good link in HTML](#link2) | Pass   | Pass     | **Fail** |
| [Bad link](#link3)          | Fail   | **Pass** | Fail     |

**Targets**

# link1

<a name='link2'>Link 2</a>

Edit: Updated for release 3.11.0

@adoyle-h
Copy link

You can try https://github.com/lycheeverse/lychee

@MikeMcC399
Copy link

@tcort

Do you have any comments on this thread?

@yusufsheiqh
Copy link

Has there been any progress on this issue?

@dklimpel
Copy link
Contributor

dklimpel commented Jun 3, 2024

I have created a PR to solve the issue.

Rreviews or suggestions for improvement are welcome.

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

No branches or pull requests

8 participants