joeyespo / grip

Preview GitHub README.md files locally before committing them.
MIT License
6.42k stars 423 forks source link

image not showing when running export #295

Closed robertmarkbram closed 5 years ago

robertmarkbram commented 5 years ago

I have the following md file where the image displays correctly (using VS Code). I am on a Windows machine and using an absolute path to the image.

Text

![](C:/Users/robert.bram/Temp/IntellijDebugConfiguration.png)

Text

I then run the following command: grip temp.md --export temp.html

<p>Text</p>
<p><a href="" target="_blank" rel="noopener noreferrer"><img alt="" style="max-width:100%;"></a></p>
<p>Text</p>

What am I missing here?

Rob :)

Bwvolleyball commented 5 years ago

@robertmarkbram - I believe you need to make the path relative. The idea behind this project is to try to replicate what a markdown document would look like if it were pushed to GitHub. This means 2 things:

1) It is assumed that the image lives within the same repo as the markdown document 2) the path to said document is relative.

That being said, if your markdown document lived in the robert.bram folder, your path in order to display the png should just be ./Temp/IntellijDebugConfiguration.png

Hope this helps!

EDIT:

To further clarify this - an absolute path would not work in GitHub, so I'd assume it won't work in this GitHub markdown renderer.

joeyespo commented 5 years ago

Hey @robertmarkbram! Thanks for the issue. @Bwvolleyball is correct. You'll need to use relative paths.

If you think about it, it makes sense. GitHub can't serve images from machine-dependent absolute paths, so you probably shouldn't do this. (Look up the file:// scheme if you absolutely need it, but I'd still recommend against this workaround.)