Closed Thiti517 closed 1 day ago
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?
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.
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 👍
@Thiti517 are you able to give the proposed fix in #75 a go?
I've updated the example configuration in the docs/
subdirectory to include mkdocs-glightbox
, and with the default configuration (emitting img
tags) it seems to work correctly. Inlining SVGs needs a little more troubleshooting.
Oh! Awesome! I was also considering moving the process to the on_page_markdown
event since it seems to be the best solution. I’ll check it out right away!
I tested it out, and it works great!
This turned out to completely break generation of image source paths, so I've yanked the 0.10.0 release until I have more time to figure it out.
Should be fixed in 0.10.1 which shipped yesterday.
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 anchorhref
. This occurs in theon_page_content
function, which means the anchor is added before your plugin modifies the imagesrc
inon_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.