tcort/markdown-link-check

404 on links to section headers that exist in the same file

philrz opened this issue · 3 comments

I've found some strange 404 errors when running markdown-link-check on the attached file zng.md.

Testing that file locally with v3.11.0, the two 404 errors are unexpected. The headers for all three of these sections look much the same in the markdown.

$ npm install -g markdown-link-check

$ markdown-link-check --version
3.11.0

$ markdown-link-check zng.md

FILE: zng.md
  [✓] #21-types-frame
  [✖] #22-values-frame
  [✖] #23-control-frame

  3 links checked.

  ERROR: 2 dead links found!
  [✖] #22-values-frame → Status: 404
  [✖] #23-control-frame → Status: 404

Then if I remove a particular line from the file, the 404 errors go away.

$ sed 's/A named type is encoded as follows://' zng.md > zng-edited.md

$ markdown-link-check zng-edited.md 

FILE: zng-edited.md
  [✓] #21-types-frame
  [✓] #22-values-frame
  [✓] #23-control-frame

  3 links checked.

I went to clone the repo so I could try debugging the problem myself, but oddly once I did that, I found my version installed from source didn't trigger the problem, even though the version is the same, which also struck me as odd.

$ npm uninstall -g markdown-link-check

$ git clone https://github.com/tcort/markdown-link-check.git

$ cd markdown-link-check/

$ git checkout v3.11.0

$ npm install

$ npm install -g

$ markdown-link-check --version
3.11.0

$ markdown-link-check zng.md 

FILE: zng.md
  [✓] #21-types-frame
  [✓] #22-values-frame
  [✓] #23-control-frame

  3 links checked.

I noticed the same thing, via MegaLinter.

✅ Linted [MARKDOWN] files with [markdown-link-check]: Found 6 non blocking error(s) - (3.51s) (expand for details)
- Using [markdown-link-check v3.11.2] https://megalinter.io/7.10.0/descriptors/markdown_markdown_link_check
- MegaLinter key: [MARKDOWN_MARKDOWN_LINK_CHECK]
- Rules config: [.markdown-link-check.json]
- Number of files analyzed: [2]
--Error detail:
(node:24) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
  ERROR: 6 dead links found in README.md !
  [✖] #requirements → Status: 404
  [✖] #providers → Status: 404
  [✖] #modules → Status: 404
  [✖] #resources → Status: 404
  [✖] #inputs → Status: 404
  [✖] #outputs → Status: 404

and my code looks like:

- [Table of Contents](#table-of-contents)
- [Usage](#usage)
  - [Examples](#examples)
- [Requirements](#requirements)
- [Providers](#providers)
- [Modules](#modules)
- [Resources](#resources)
- [Inputs](#inputs)
- [Outputs](#outputs)
- [GitLab Groups and Projects (Repositories)](#gitlab-groups-and-projects-repositories)
- [Maintainers](#maintainers)
- [Contributing](#contributing)

To resolve this, I put <!-- markdown-link-check-disable --> before the code and <!-- markdown-link-check-enable --> after the code. Then I received this:

✅ Linted [MARKDOWN] files with [markdown-link-check] successfully - (3.47s) (expand for details)
- Using [markdown-link-check v3.11.2] https://megalinter.io/7.10.0/descriptors/markdown_markdown_link_check
- MegaLinter key: [MARKDOWN_MARKDOWN_LINK_CHECK]
- Rules config: [.markdown-link-check.json]
- Number of files analyzed: [2]

Same here. I've encountered the exact same issue. After conducting some tests, I believe something broke starting with version 3.12.1.(v3.12.0 is broken for me to verify the issue) Testing with version 3.11.2 yields no such problems.

I'm currently encountering an issue that seems to be similar across different software versions, though there appears to be some variation in the specific versions impacted.

Initially, I experienced this problem with version 3.11.0. However, after some troubleshooting, version 3.11.0 is now functioning correctly for me, but I don't know why. And, the issue persists with the latest release, version 3.12.1. The problem may be consistent across these versions, albeit manifesting under slightly different conditions or configurations.