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

pymdownx.tabbed breaks relative-url-rewrite for nested imports #179

Open
9Lukas5 opened this issue Sep 30, 2023 · 4 comments
Open

pymdownx.tabbed breaks relative-url-rewrite for nested imports #179

9Lukas5 opened this issue Sep 30, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@9Lukas5
Copy link

9Lukas5 commented Sep 30, 2023

I have the following example structure:

docs
├── a
│   ├── assets
│   │   └── screenshot.png   
│   ├── page-a.md                       # imports _part-site.md
│   ├── _part-site.md                   # imports _screenshot.md
│   └── _screenshot.md              # has image with relative path to assets/screenshots.png
├── b
│   └── page-b.md                       # imports ../a/part-site.md
└── index.md

While the on page-a the image is shown fine, on page-b it is not found, as the relative image url wasn't rewritten correctly.

This behaviour is only the case, when in _part-site.md the _screenshot.md is included into a pymdownx.tabbed tab.

Attached is a minimal example for this scenario

@mondeja
Copy link
Owner

mondeja commented Oct 12, 2023

This is the expected behaviour as the _part-site.md file includes _screenshot.md which is just a replacement for:

This is the screenshot site from `docs/a`

![Some title](./assets/screenshot.png)

The link is just handled by Mkdocs as if the file were in the same relative folder. I think that you need to use an absolute path. What behaviour you would expect here?

@mondeja mondeja added the question Further information is requested label Oct 12, 2023
@9Lukas5
Copy link
Author

9Lukas5 commented Oct 12, 2023

Outside of the tabbed environment the plugin successfully rewrites the relative path accordingly, so the image shows in the a and b subpaths 👀

@mondeja
Copy link
Owner

mondeja commented Oct 14, 2023

I'm not experiencing the same behaviour as you with the example that you've shared. The path is not rewritten correctly when is not included into a pymdownx.tabbed tab.

@mondeja mondeja closed this as completed Oct 14, 2023
@9Lukas5
Copy link
Author

9Lukas5 commented Oct 15, 2023

With the example originally shared you don't, yes, because that was designed to show-off what was an obvious bug to me. I didn't include it to show that it is working under b/ if the import of _screenshot.md in a/_part-side.md was done outside the tabbed environment.

But that can be changed, see below:

As for your this:

This is the expected behaviour as the _part-site.md file includes _screenshot.md which is just a replacement for...

The readme states:

rewrite-relative-urls (true): When this option is enabled (default), Markdown links and images in the content that are specified by a relative URL are rewritten to work correctly in their new location. Possible values are true and false.

So, with the updated example you can see, with the include chain page-b.md -> _part-site.md -> _screenshot.md the image relative url rewrite works for the _screenshot.md include that is not indented, but is broken for indented lines.

Oh and as I'm writing this, I discovered it's not limited to the tabbed environment, it's also broken if indented into a list (see example code)

So I'm sorry, but according to the readme and the fact that it's working without additional environments (like lists, tabbed,...) around it, I'm still thinking of this as a bug or at least a mentionable technical limit, but not expected behaviour.

@mondeja mondeja reopened this Oct 16, 2023
@mondeja mondeja added bug Something isn't working and removed question Further information is requested labels Oct 16, 2023
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