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

Embed images #138

Closed
zzart opened this Issue Sep 5, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@zzart

zzart commented Sep 5, 2014

According to the docs

mkdocs.yml
docs/
    CNAME
    index.md
    subpage.md
    img/
        screenshot.png
index.md
![Screenshot](img/screenshot.png)

This is all good if you adding images to index.md

Now let's consider subpage:

subpage.md
![Screenshot](img/screenshot.png)

This image isn't found as server wants it to be in subpage/img/screenshot.png ??
So this forces invalid markup which doesn't work with other MD engines!

subpage.md
![Screenshot](../img/screenshot.png)
@dnrce

This comment has been minimized.

Contributor

dnrce commented Sep 14, 2014

👍

@d0ugal d0ugal added the Bug label Oct 1, 2014

@d0ugal

This comment has been minimized.

Member

d0ugal commented Oct 7, 2014

The problem, is that subpage.md moves to subpage/index.html and thus the relative location of the img is incorrect. To fix this I think we need to infer an abolute location (by resolving the relative one to the .md file) and then use for image links.

However, AFAICT, this will involve processing and re-writing the HTML which would get messy.

Any better ideas?

@d0ugal d0ugal added this to the 0.10.0 milestone Oct 7, 2014

@tomchristie

This comment has been minimized.

Contributor

tomchristie commented Oct 7, 2014

I'm confused. As far as I'm aware we do infer the correct relative location, which when translated into a URL will differ depending on if it was a link from subpage.md or index.md.

To fix this I think we need to infer an abolute location

I can't see why we'd need to be moving away from the current relative URLs, although if they're currently incorrectly generated for non-index pages then that needs fixing of course.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Oct 7, 2014

How should an image be added on subpage.md? Given the structure above? Maybe we just need to document this better, I don't fully understand but requiring people to put "../" seems wrong when that extra level isn't there in the source files.

@tomchristie

This comment has been minimized.

Contributor

tomchristie commented Oct 7, 2014

Yup indeed - the source should be marked up as ![Screenshot](img/screenshot.png) in both cases, but the translation to HTML should render different links in each case, including the required .. in one case but not in the other. As far as I was concerned we're handling both cases correctly when we translate them into relative URLs, but haven't checked lately.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Oct 7, 2014

Right, so I tested this and confirmed the issue. I'll investigate the fix. I'm not sure which bit of the code is responsible for this yet.

d0ugal added a commit to d0ugal/mkdocs that referenced this issue Oct 8, 2014

@d0ugal d0ugal modified the milestone: 0.10.0 Oct 9, 2014

@d0ugal d0ugal closed this in #148 Oct 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment