comwes / mkpdfs-mkdocs-plugin

Converts your mkdocs documentation in PDF, to be shared with users
https://comwes.github.io/mkpdfs-mkdocs-plugin
GNU General Public License v3.0
103 stars 36 forks source link

Fix link across multiple documents #35

Closed j123b567 closed 3 years ago

j123b567 commented 3 years ago

Generating links and appropriate ids was overcomplicated witch results in multiple unhandled edge cases. File name extensions were removed, relative paths were not properly handled in all cases, etc. So it sometimes breaks linking between documents.

This PR just simplify all things and remove unnecesery URL manupulations. It generates unique and consitant ids and hrefs.

It works well with both use_directory_urls: False and also use_directory_urls: True.

It generates same ids and hrefs in all cases, where original implementation works, and correct ids and hrefs in all other cases, where original implementation fails. One exception is just that with use_directory_urls: False urls and ids now also contains file name extensions, which just works. There is no need to remove them.

This also leads to not breaking external URLs.

trogper commented 3 years ago

Does it correctly support diacriticals in headings?

comwes commented 3 years ago

Does it correctly support diacriticals in headings?

I think reading the following issue can answer your question. https://github.com/squidfunk/mkdocs-material/issues/8

trogper commented 3 years ago

I actually meant headings, not filenames. I have experienced some issues with href links not working when headings had diacriticals in them. This probably might not apply to pdf links

comwes commented 3 years ago

Could you provide an example so I can test and confirm your issue is fixed by this or create a new one?

trogper commented 3 years ago

Now I remember what the issue was. It was caused, I think, by mkdocs itself. When you had heading on a page with diacritics, the element id (used for hash navigation) skipped diacritical letters (heading "Červená máňa" had id "erven-ma") which was very impractical. We resorted to using uslugify, which stripped only diacriticals, not whole letters. You can probably take my comments just as a "reminder" to test tolerance to unicode characters

comwes commented 3 years ago

@trogper noted, I'm planning to have a test forlder to test particular behavior such the one you have reported. Thanks.