Markdown-preview-enhanced: Absolute image paths (/img.png)

Created on 27 May 2016  ·  10Comments  ·  Source: shd101wyy/markdown-preview-enhanced

Some markdown parsers support absolute paths like (/path/to/image.png). The root folder denotes to the root of the project. Example:
https://github.com/kachkaev/linter-markdown-51/blob/master/README.md

These absolute references are useful in cases when an online markdown viewer does not support relative URLs with ../. From my experience, ../path/to/image.png does not work in gitlab. Absolute links are also handy when you move the files around the repository – you do not have to edit them each time. Bulk finding and replacing /path/to/image.png is also easier than trying to find all relative links to it: path/to/image.png, to/image.png, ../../to/image.png, etc.

It would be nice if markdown-preview-enhanced knew about absolute paths and could show the images that are embedded in such a way.

Most helpful comment

Ok i see. I only considered one project when implementing absolute path. I will fix this issue this weekend.

Thanks

All 10 comments

Hi @kachkaev , sorry for my late reply

Absolute image path is now supported.

Markdown file link also supports absolute path.
For example [test.md](/docs/test.md) now works

Please upgrade to the newest version, then restart atom

Cheers ;)

Hi @shd101wyy , when export to HTML, the relative path (e.g.images/image.png ) will be converted to absolute path instead of using relative path, it makes the html file cannot find correct image path once the html file is moved.

I will fix it later. Thanks!

Hi @ckdanny , it should work now.

Please upgrade the package ;)

Sorry for the trouble.

Looks like there is one tiny issue left with absolute paths, which is quite easy to reproduce.

If there is more than one project in a list on the left, absolute paths to images inside .md only work for the first one of them. Changing the order of the projects affects the result of the preview. Looks like this is to do with how the package resolves the paths.

Interestingly, it is possible to refer to an image in one project from another one. E.g.:

   img-a.png

project-b
    img-b.png
    README.md

 
README.md:

![](/img-a.png) ← works, but should not 
![](/img-b.png) ← does not work, but should

Ok i see. I only considered one project when implementing absolute path. I will fix this issue this weekend.

Thanks

Hi @kachkaev , should be fixed now ;) Thanks

It worked, thank you @shd101wyy!

It seems this feature has some problems working with project-manager. Since I would switch between multi projects, markdown-preview-enhanced sometimes uses root path of project B when I'm editing a file in project A.

It worked !!! Wow!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oneone1995 picture oneone1995  ·  5Comments

fengxs269 picture fengxs269  ·  4Comments

StefanoCecere picture StefanoCecere  ·  5Comments

adamaltmejd picture adamaltmejd  ·  5Comments

AdexoMing picture AdexoMing  ·  3Comments