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

Compatibility Issue with mkdocs-glightbox #72

Open
Thiti517 opened this issue Oct 17, 2024 · 3 comments
Open

Compatibility Issue with mkdocs-glightbox #72

Thiti517 opened this issue Oct 17, 2024 · 3 comments

Comments

@Thiti517
Copy link

Hello!

First of all, I have to say that your plugin has saved me a lot of time in converting Draw.io files to PNG.

I found an issue when using it alongside the mkdocs-glightbox plugin. This plugin wraps images with an anchor tag, using the image src as the anchor href. This occurs in the on_page_content function, which means the anchor is added before your plugin modifies the image src in on_post_build function (if I understand your code correctly).

As a result, the anchor href remains broken, still pointing to the original .drawio file rather than the generated .png, .svg, or other formats created by your plugin.

@LukeCarrier
Copy link
Owner

Thanks for raising this, it sounds like the ordering of the hooks matters. I'm not sure how MkDocs determines the precedence of plugins, but I wonder if reordering them in the plugins key of mkdocs.yml is enough?

Do you have an example I could clone to test?

@Thiti517
Copy link
Author

Unfortunately, changing the plugin order in mkdocs.yml won’t solve the issue. MkDocs processes each event sequentially, and for each event, it checks the plugins (in the order listed in the config) to see if they have a corresponding function like on_event. If a plugin uses an event that occurs after the one used by mkdocs-glightbox, the order of plugins won’t make a difference.

A better solution would be to modify your plugin so that it updates the image link during the on_page_markdown event instead of on_post_build. The on_page_markdown event happens before on_page_content, which is when mkdocs-glightbox wraps the images.

I'll try to create an example project when I find more time in my currently tight schedule. If possible, I'll also work on a pull request with the modifications I believe could solve the issue.

@LukeCarrier
Copy link
Owner

I'm rewriting the images in on_post_page, but copying the images in on_post_build.

Happy to accept a PR or take a look myself, time permitting 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants