mkdocs-htmlproofer-plugin icon indicating copy to clipboard operation
mkdocs-htmlproofer-plugin copied to clipboard

fails on `../file.md#anchors`

Open nahuhh opened this issue 1 year ago • 6 comments

Describe the bug fails on anchors such as:

Please see the [project license](../about.md#license) for further details.

../about.md will pass, but adding the #license causes it to fail

Environment (please complete the following information): Mkdocs 1.6.1 mkdocs-material 9.5.34

htmlproofer vers 1.3.0

nahuhh avatar Sep 21 '24 09:09 nahuhh

Upd8. This if also relevant for external links that have anchors

nahuhh avatar Sep 22 '24 10:09 nahuhh

@nahuhh Do you see this issue in previous versions?

manuzhang avatar Sep 23 '24 00:09 manuzhang

@nahuhh Do you see this issue in previous versions?

I haven't tried previous versions. I'll test

nahuhh avatar Sep 23 '24 13:09 nahuhh

Works on <=1.2.0 fails on >=1.2.1

nahuhh avatar Sep 23 '24 13:09 nahuhh

@nahuhh Do you have a minimal example?

manuzhang avatar Sep 23 '24 15:09 manuzhang

I am having a similar issue here. I am using mkdocstrings to generate autodocumentation of the whole repository in a recursive manner. The problem in my case seems to be on cross-references. If I cite a function (::: my_package.function) and this function receives input arguments that are, at the same time, in another file, it will break despite links are always fine.

In this case, _factory.md (generated in a recursive manner) contains a reference to MyData in some signatures. MKDodcstrings creates a crossed reference to MyData and it works well. However, htmlproofer reports all these kind of links as error:

    WARNING:mkdocs.utils:htmlproofer: Unable to locate source file for: ../../data/my_data/#my_project.data.my_data.MyData
    WARNING:mkdocs.utils:htmlproofer: invalid url - ../../data/_my_data/#my_project.data._my_data.MyData[404] [files\autodoc\_demo_datasets\_factory.md]

All warnings have the same pattern in common: they also reference anchors.

One important thing is that before, htmlproofer did not report anything before. I think it started happening after some packages were updated.

I will try to get a minimal example

mflova avatar Mar 12 '25 07:03 mflova

I have observe the same problem with

  • Mkdocs 1.6.1
  • mkdocs-material 9.5.15
  • htmlproofer vers 1.3.0 (same with 1.4.0)

Broken link

Please see the [project license](../about.md#license) for further details.

pointing to a Markdown file with inline html (in a table)

<td rowspan="9"><a name="license"></a>foo bar</td>

I also tried different html anchors/tags/divs without luck

<td rowspan="9"><a href="license"></a>foo bar</td>
<td rowspan="9"><div id="license">foo bar</div></td>

Also is to be noted that the link does work when I build the website and test it locally or deploy it.

matlupi avatar Nov 06 '25 10:11 matlupi

@matlupi Thank for reporting. I will take a look later tonight.

manuzhang avatar Nov 06 '25 11:11 manuzhang

@matlupi <td rowspan="9"><a id="license"></a>foo bar</td> works for me. Could you please check?

manuzhang avatar Nov 06 '25 12:11 manuzhang

@nahuhh Do you have a minimal example?

you should be able to build https://github.com/monero-project/monero-docs to reproduce. You'll have to manually install htmlproofer

nahuhh avatar Nov 14 '25 06:11 nahuhh

@nahuhh Do you have a minimal example?

you should be able to build https://github.com/monero-project/monero-docs to reproduce. You'll have to manually install htmlproofer

@matlupi 's minimal exammple here seems to be the same

nahuhh avatar Nov 14 '25 06:11 nahuhh