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

fix_internal_links only fixes pages and images, but not attachments #42

Closed
EricDuminil opened this issue Feb 15, 2021 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@EricDuminil
Copy link

One of my documentation websites offers internal links to Python scripts, text files and spreadsheets. Downloading those files work as expected from the MkDocs website.

The corresponding links get converted to anchors by mkdocs-print-site-plugin, though, and cannot be accessed anymore from the print_page or the resulting PDF.

For example, in Markdown:

[`hello.py`](../attachments/scripts/hello.py){target=_blank}

gets converted by MkDocs to:

<a href="../../attachments/scripts/hello.py" target="_blank"><code>hello.py</code></a>

and then by mkdocs-print-site-plugin:

<a href="#attachments-scripts-hello.py" target="_blank"><code>hello.py</code></a>

But this anchor doesn't exist.

Could it be possible to fix the resulting urls, like, AFAICT, fix_image_src does for images?

One quick-and-dirty fix I found is to modify https://github.com/timvink/mkdocs-print-site-plugin/blob/master/mkdocs_print_site_plugin/urls.py#L100 in order to consider those attachments as external url:

    if is_external(url) or url.endswith('.py') or url.endswith('.xlsx') or url.endswith('.txt'):
        continue

It might be a good idea to also apply add_full_urls: true to those attachments, so that the corresponding files can still be found even when the documentation is printed to paper.

@timvink timvink added the bug Something isn't working label Feb 22, 2021
@timvink
Copy link
Owner

timvink commented Feb 22, 2021

Thanks for this one! Another edge case I had not foreseen. Your example and potential solution really helped in fixing this as well.

Should work in v1.1 now (https://github.com/timvink/mkdocs-print-site-plugin/releases)

@timvink timvink closed this as completed Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants