MarkdownViewerPlusPlus
MarkdownViewerPlusPlus copied to clipboard
 can not display
Using

can`t work well and pictures not display.
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.

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:



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).
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.)
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:
- naively searches for a colon (
:
) to identify presence of protocol- can fail if using local path (e.g.
C:\Users\...
) becauseC:\
contains a colon
- can fail if using local path (e.g.
- uses
Path.IsPathRooted
[ref?] to determine iffile:///
prefix is necessary- which will never return true for relative paths (almost certainly the type you are using)
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:
- These formats don't work:
-
red X

-
red X

-
gray stopwatch

-
gray stopwatch

-
red X
- But these formats do:
-

-

-

-

-

-

(not a valid absolute path!)
-
Refer to #50.
Same problem.
 use a lot in github, then 