byrnereese / linkchecker-mkdocs

Python asyncio + aiohttp Markdown *.md URL link checker: 10,000 files/second
MIT License
9 stars 4 forks source link

There is something odd going on with images #3

Open faxm0dem opened 2 years ago

faxm0dem commented 2 years ago

I have the following project:

site_name: Dummy - Site
site_url: https://example.com/dummy
site_dir: public
nav:
  - Index: index.md
  - Foo: foo.md

Both markdown files contain the following:

# Lemming

![Lemming](img/lemming.jpg)

If I run mkdocs-linkchecker it finds one problem in file foo.md:

☠ mkdocs-linkcheck -l docs/
Total files checked: 2
Total links checked: 2
        Local links: 2
       Remote links: 0
        Empty links: 0
       Broken links: 1
      Skipped links: 0

/tmp/dummy/docs/foo.md:
[✖] img/lemming.jpg
0.00154 seconds to check links
Bad links were found. Exiting with an error.

Please note it is happy about index.md even though it's the same file. Also note that mkdocs serve is perfectly happy, and the site displays the image on both pages.

Now if I use ../img/lemming.jpg in foo.md instead:

# Lemming

![Lemming](../img/lemming.jpg)

Then, mkdocs-linkcheck is happy:

☠ mkdocs-linkcheck -l docs/
Total files checked: 2
Total links checked: 2
        Local links: 2
       Remote links: 0
        Empty links: 0
       Broken links: 0
      Skipped links: 0
0.00129 seconds to check links

However, mkdocs serve isn't:

☠ mkdocs serve
INFO     -  Building documentation...
INFO     -  Cleaning site directory
WARNING  -  Documentation file 'foo.md' contains a link to '../img/lemming.jpg' which
            is not found in the documentation files.
INFO     -  Documentation built in 0.06 seconds
INFO     -  [12:19:41] Watching paths for changes: 'docs', 'mkdocs.yml'
INFO     -  [12:19:41] Serving on http://127.0.0.1:8000/dummy/

Please note that both configurations work fine, both pages display the picture fine.