nea / MarkdownViewerPlusPlus

A Notepad++ Plugin to view a Markdown file rendered on-the-fly
MIT License
1.17k stars 143 forks source link

![xxx](xxx.jpg) can not display #38

Open befeng opened 7 years ago

befeng commented 7 years ago

Using ![xxx](xxx.jpg)

can`t work well and pictures not display.

p11h commented 7 years ago

This issue has been raised before (see #23 and #30).

If exporting to HTML your example works as expected, so this is only an issue in the viewer or if exporting to PDF.

While it is currently possible to workaround the issue by including the file:/// prefix, I would say that it is non-standard and non-intuitive, and would like the issue to be revisited if possible.

![xxx](file:///xxx.jpg)

Edit: Adding file:/// will work to display in the viewer, but export to HTML or PDF fails to render the image unless the full path is given:

![xxx](file:///xxx.jpg)
![xxx](file:///./xxx.jpg)
![xxx](file:///C:/test/xxx.jpg)

All three of these examples will render in the viewer, but only the final example (with full path) will render in the browser (at least while testing locally).

heydojo commented 6 years ago

This issue has been raised before (see #23 and #30).

And both of those issues are closed and the issue remains.

The issue is that images do not display in the preview pane or in exported pdf documents. Using the file:/// protocol does not provide the desired result.

It appears to be a pathing issue and is likely caused by MarkdownViewerPlusPlus using Notepad++'s current path instead of the current document's path? This would cause the plugin to fail to resolve the relative path of a linked image.

Likely somewhere in: https://github.com/nea/MarkdownViewerPlusPlus/commit/86d66788c45c1d4b7bb158b5fe9427d52a3a947f may be the place to ensure that the resolved path to an image is relative to the open document root if the path to the image is not prefixed with a protocol directive (eg. http or ftp.)

patricktokeeffe commented 5 years ago

There is already code that attempts to prefix local image paths with "file:///" ... https://github.com/nea/MarkdownViewerPlusPlus/blob/1a3dddc525913995bd65b6c7d6a6c11a1c2ca7f3/MarkdownViewerPlusPlus/Forms/MarkdownViewerRenderer.cs#L134

...but it has some issues:

This could be fixed up by using a regular expression to identify protocol prefixes and dumping the IsPathRooted check.


FWIW, the current situation has very strange behavior. With an image located in images/ subfolder:

andrzejQ commented 5 years ago

Refer to #50.

sonichy commented 5 years ago

Same problem.

![xxx](xxx.jpg) use a lot in github, then ![xxx](http://xxx.jpg)