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

Relative html img links are referencing non existing locale files since v1 #275

Closed
machinaeXlasse opened this issue Oct 24, 2023 · 5 comments

Comments

@machinaeXlasse
Copy link

machinaeXlasse commented Oct 24, 2023

If I define a link to an img in my documentation and use markdown style

![screenshot](./assets/live_toggle.png)

The image path will be adapted to always find the non localized image in either language file

If I define a link to an img and use html

<img src="./assets/live_overview.png" alt="screenshot"/>

The image path will only work for the default language since the relative path is kept intact and will not find anything at .../fr/assets/live_overview.png

I understand that there have been changes to improve efficiency for non locale assets as described in #252

Though I would expect that html (img) links are treated similar to markdown image tags and are being converted.

Maybe I am just missing something.

I use mkdocs_static_i18n-1.1.1
with mkdocs-1.5.3
and mkdocs_material-9.4.6

Thanks a lot for your beautiful work!

@machinaeXlasse
Copy link
Author

Issue has been fixed with v1.2.0

Sorry for the hassle, probably could have seen it coming with the pending pull request. Thank you!

@kamilkrzyskow
Copy link
Contributor

Actually version 1.2.0 didn't add anything after 1.1.1 that would influence this behavior.

Also I don't think MkDocs processes the links of images written in HTML instead of Markdown, but as you say it's fixed, then perhaps some other version fixed that and you haven't used it before 🤔

@machinaeXlasse
Copy link
Author

Uh, I'm sorry the problem is not fixed actually. I was looking at the wrong part of the docs .

So am I right that, since images (files) are not moved to the language dir anymore, html links will "break" because they are not processed?

Do you have an idea how to deal with this? Since html has more features in how images are displayed it is the favored choice in some places.

@kamilkrzyskow
Copy link
Contributor

If I understand correctly the image name and extension doesn't change, just the relative path of directories to it.
As mentioned in this comment (#256 (comment)) you could use absolute paths, but as I point out in the comment below (#256 (comment)), you need to keep in mind the real base path, as it might be /repository-name/ instead of just /. Also in the case you change the name of the base path you would have to modify every link ✌️

Since html has more features in how images are displayed it is the favoured choice in some places.

What other features do you have in mind? You can add CSS classes or other attributes with the attr_list extension to display the images in a different way. https://python-markdown.github.io/extensions/attr_list/

markdown_extensions:
  - attr_list
![screenshot](assets/live_toggle.png){ style='width: 50%;' }

@machinaeXlasse
Copy link
Author

I see, thanks for the clarification!

The attribute list hint is great! Didn't come to my mind even though we already used the extension for another purpose. I will have a go with it. Some 200 html tags need to be replaced but then the style is also more consistent. I may not forget to add this in the docs contibution guidelines 😉

You can add CSS classes or other attributes with the attr_list extension to display the images in a different way. https://python-markdown.github.io/extensions/attr_list/

Serves as a very good solution for me.

I will leave a note that, without knowing anything about the underlying process, I would love relative links in html tags to be working with multiple language directories.

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