mb21 / panwriter

Markdown editor with pandoc integration and paginated preview.
https://PanWriter.com
GNU General Public License v3.0
1.04k stars 49 forks source link

preview window can't show the local image #5

Open asmwarrior opened 5 years ago

asmwarrior commented 5 years ago

Hi, if I have a file named "text.md", and a file "a.png" is put in the same folder of this markdown.

![a](a.png)

This code does not show the image in the preview window, can you enable this? I think the local image(usually they have relative path to the md file) should be shown correctly.

Thanks.

mb21 commented 5 years ago

This works for me as well, but probably has to do with Windows backslashes or something like that.

In PanWriter, can you try View -> Toggle Developer Tools and see whether you can find the iframe that's used for the preview and see whether it contains a base tag like <base href=""> in the <head>? That base tag should be set to point to your current directory.

mb21 commented 5 years ago

I just tested on a Windows 10 VM and it worked fine for me.

If you can reproduce this, let me know... and what your <base> tag looks like.

achimwagenknecht commented 2 years ago

I can reproduce this error on my Windows 10 VM. Editor: ![*Klicken Sie hier*](01.png) Preview: broken image DevTools: <img src="file:///01.png">

I tried the following without success:

achimwagenknecht commented 2 years ago

Thank you for reopening. Now I encounter the same error on Linux as well... But here the error is easily fixed: There was a space character in the file's path. Removed it, now it works. Tried the same solution on Windows, but unfortunately it doesn't do the trick. I also looked for other special characters in the path but did not find any.

Moonbase59 commented 1 year ago

Linux Mint 21.1 & Panwriter AppImage 0.8.5 here: Images don’t display if there is a blank anywhere in the path of the generated file://… link. I like this project but this makes it rather unusable for me, because I can’t change my existing folder structures (using lots of UTF-8 characters and blanks in the folder names).

Test_005

Test_006

Maybe it’s just a problem of URL-encoding. I seem to remember when there was a blank in the path (as in "Panwriter Test"), it tried to make a file://… link having a %20.

Also, if you look closely at the second screenshot, it generates an extra slash in the file://… link between the path and the image name part: file:///home/matthias/Dokumente/Panwriter-Test//Moonbase-new-Logo.svg.

mb21 commented 1 year ago

@Moonbase59 The spaces in the url not working seems to be correct behaviour according to Commonmark, see e.g. this example. You should be able to use %20 instead of a space.

About the double slash between folder and image name: thanks, should be fixed with https://github.com/mb21/panwriter/commit/1665eab73ef9b521706e0a901b6d13da8d2fe165

Darthagnon commented 1 year ago

I'm seeing the same issue: relative images do not render on Windows. They render fine in Notepad++ using https://github.com/mohzy83/NppMarkdownPanel