mkdocs-pdf-export-plugin: Links in combined PDFs are still broken
Running mkdocs-pdf-export-plugin 0.5.3, relative links between pages are still pointing to local file locations:

It looks like this was fixed in #28 but may have regressed since then. I’ve tested this in my existing projects and in a clean test project (as shown in the screenshot above, relative links are all pointing to file:///C:... locations. The links work properly in rendered HTML.
During the build, the same error gets thrown four times (the test project has only 3 pages), which seems like the same thing experienced in #42:
ERROR: No anchor #/.:pdf-export-test for internal URI reference
ERROR: No anchor #/.:pdf-export-test for internal URI reference
ERROR: No anchor #/.:pdf-export-test for internal URI reference
ERROR: No anchor #/.:pdf-export-test for internal URI reference
There is no file called pdf-export-test in the test project, but that is the H1 on the index.md page.
I’d be happy to provide the test project if it would be helpful. I could take a stab at a PR but I’m still learning my way around the code (and know nothing about WeasyPrint, unfortunately).
And lastly, this project is a lifesaver! Thank you so much for your work and active support. It is greatly appreciated.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 4
- Comments: 15 (4 by maintainers)
ANy news ? I used the use_directory_urls to false, but the error is always here for subdirectory link…
Sorry to drop this, was away for a couple of weeks!
This workaround fixes one problem – I no longer get pointed at local files – but it looks like there was another issue hiding behind that one.
Now that the local file links are fixed (or worked around), some links work, but some links just render as styled text that doesn’t go anywhere.
docs/level, to other pages at the same level, work as expected 🎉.docs/level with anchors, like[link](file.md#heading), or with only anchors, like[link](#heading), do not work.docs/folder/file.md) seem to never work no matter what.I’ve expanded my test project to show these individual cases. If I can add test cases that would be helpful for you, I’m happy to build it out further. Also if this looks like a totally different issue to you, we can close this off and start a new one.
Revised test project: pdf-link-test-project.zip
Rendered PDF: test.pdf
Build output (not verbose this time because whoa): output.txt
Here’s the test project I’m using. I was curious if it was a Windows issue so opened the project on a Linux/Ubuntu desktop but am seeing the same behavior; PDFs are created successfully but links are pointing to local files instead of locations within the PDF. I also get errors for each head tag in the project, as above (this one is slightly different than my original report because I re-created everything from scratch).
Other details that may be useful:
Project: test.zip
Generated PDF: combined.pdf
Verbose build output (or most of it anyway, it filled up my buffer so we’re missing the beginning) console-output.txt
Thanks again for looking into it!
@CaptainQuirk sorry, forgot to watch my notifications. I cobbled together a solution for this (actually completely rebuilt the path generator) and it works for our team, but I wasn’t able to submit a PR here and then forgot about it.
I’ve forked this project and updated it with my code, you’re welcome to use it (the fork is not registered with pypi so you can’t use pip to install it, you’ll need to install it manually or copy the plugin files over this install.
https://github.com/erilot/mkdocs-pdf-export-plugin
@zhaoterryy I would be happy to submit this as a PR here but i think you have to allow that.
Is there any work planned for supporting directory urls? Please let me know how we can help on getting this awesome feature in 😃
I’m also experiencing the same with the latest version 0.5.5. Is there any setting we have to put in place to make this work?
I found the issue. For the time being,
use_directory_urlsmust be set to false. https://www.mkdocs.org/user-guide/configuration/#use_directory_urlsNeed to write a separate href builder for directory urls.
On my part, trying out the
0.5.3version didn’t solve my problem in #42.I still get
No anchor #cp/show/:charge-de-communication for internal URI referencefor the markdown constructEn tant que [Chargé de communication](../glossaire.md#charge-de-communication)👍 for the appreciation of the whole project