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

Links in combined PDFs are still broken #43

Open
erilot opened this issue Feb 19, 2019 · 16 comments
Open

Links in combined PDFs are still broken #43

erilot opened this issue Feb 19, 2019 · 16 comments
Labels
bug Something isn't working investigate needs investigation

Comments

@erilot
Copy link

erilot commented Feb 19, 2019

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

image

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.

@CaptainQuirk
Copy link

On my part, trying out the 0.5.3 version didn't solve my problem in #42.

I still get No anchor #cp/show/:charge-de-communication for internal URI reference for the markdown construct En tant que [Chargé de communication](../glossaire.md#charge-de-communication)

👍 for the appreciation of the whole project

@zhaoterryy
Copy link
Owner

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).

Yes please provide an example, my project here doesn't reproduce this issue. Thank you!

@zhaoterryy zhaoterryy added bug Something isn't working investigate needs investigation labels Feb 21, 2019
@erilot
Copy link
Author

erilot commented Feb 22, 2019

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).

ERROR: No anchor #/.:pdf-export-test-project for internal URI reference
ERROR: No anchor #/.:pdf-export-test-project for internal URI reference
ERROR: No anchor #/.:pdf-export-test-project for internal URI reference
ERROR: No anchor #/.:pdf-export-test-project for internal URI reference
ERROR: No anchor #/.:subheading for internal URI reference

Other details that may be useful:

  • Weasyprint: 45
  • mkdocs-pdf-export-plugin: 0.5.3
  • mkdocs: 1.0.4
  • mkdocs-material: 4.0.1 (also tested with 3.2.0)
  • Linux/Ubuntu 18.04 (also tested with Windows 10)
  • Python 3.6.7

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!

@zhaoterryy
Copy link
Owner

I found the issue. For the time being, use_directory_urls must be set to false. https://www.mkdocs.org/user-guide/configuration/#use_directory_urls

Need to write a separate href builder for directory urls.

@erilot
Copy link
Author

erilot commented Mar 12, 2019

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.

  • Links in pages at the root docs/ level, to other pages at the same level, work as expected 🎉.
  • Links in pages at the root docs/ level with anchors, like [link](file.md#heading), or with only anchors, like [link](#heading), do not work.
  • Links in pages under subfolders (for example, 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

@zhaoterryy
Copy link
Owner

@erilot try updating to v0.5.5, that should fix those issues.

@majkinetor
Copy link

Not only broken, but unclickable.

@sebastienlevert
Copy link

sebastienlevert commented Apr 8, 2019

I found the issue. For the time being, use_directory_urls must be set to false. https://www.mkdocs.org/user-guide/configuration/#use_directory_urls

Need to write a separate href builder for directory urls.

Is there any work planned for supporting directory urls? Please let me know how we can help on getting this awesome feature in :)

Not only broken, but unclickable.

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?

@CaptainQuirk
Copy link

@zhaoterryy @erilot any news on this ?

I'm still having issues with links containing anchors and several ../ in their paths

@erilot
Copy link
Author

erilot commented Nov 16, 2019

@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.

@zhaoterryy
Copy link
Owner

@erilot You should be able to submit a PR, I've accepted other's before. If you're still unable to then I can manually create one myself from your repo.

Thanks!!

@erilot
Copy link
Author

erilot commented Nov 18, 2019

@zhaoterryy you're totally right, I don't know what I did wrong before.

PR is here: #64

@majkinetor
Copy link

majkinetor commented Dec 10, 2019

FYI, I created docker mkdocs framework which uses this plugin among other things.

You can view generated demo output here:

and download pdf

You can see that first links aren't clickable but later on second page so called magic links are clickable.

See requirements for dependency details.

@igorcavalcante
Copy link

I found the issue. For the time being, use_directory_urls must be set to false. https://www.mkdocs.org/user-guide/configuration/#use_directory_urls

Need to write a separate href builder for directory urls.

Thanks, it solved my problem today!

@fletort
Copy link

fletort commented Jul 22, 2020

ANy news ? I used the use_directory_urls to false, but the error is always here for subdirectory link....

@FlorianHeigl
Copy link

The PR seems stuck... I also still get this kind of problems (anchor used in file in subfolder), too tired to try out why the patch has a conflict :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigate needs investigation
Projects
None yet
Development

No branches or pull requests

8 participants