goneovim
goneovim copied to clipboard
Markdown preview window and local images
When writing markdown one can reference an image via 
however this does not work in goneovim returning a broken image when executing the markdown preview even if img.jpg is in the same directory as the markdown file.
I have never used QT however some documentation digging on QWebEngineView seems to imply that when using SetHtml
one has to pass a base URL, otherwise relative images are not loaded. I quickly tested that by rebuilding with markdown.go:59
set to m.webpage.SetHtml(m.getHTML(content), core.NewQUrl3("file://", 0))
I have been able to load images where the markdown contains an absolute path (as in /Users/...../something.jpg
).
In order for things to work correctly I think the path would have to be set here to file://
plus the path of the loaded neovim file. Is this something you could fix? I'd love to be able to use goneovim to preview vimwiki files in markdown format with inline images without having to use an external browser.
Hi, Thank you for your contribution. I've tried to improve the ability to view local resources in the Markdown Viewer based on your comments. https://github.com/akiyosi/goneovim/commit/6854c8fb996d71e8df60f8b61ebc799204de0d39
By the way, for some external cause, CI is no longer successful. If you have the time, I would appreciate it if you could build it and see if it works.
thanks for the quick patch! I tried it and from what I can see it is using as the base directory the current neovim directory, not the directory the file is in. Meaning, say I open goneovim, the directory is set to $HOME, then I :e ~/some/dir/file.md
then what you println in the debug statement is still $HOME, so if file.md has an img.jpg
in the same directory and is referenced with (img.jpg)
it won't find it. If I :cd ~/some/dir/
and close/reopen the markdown preview it will find it.
As I was saying above I think that for the base URL it should use the path the file is in (in this case ~/some/dir
) regardless of where the cwd for neovim is: what do you think?
I understand your point. I simply changed it to get the base path of the file. I'm a little worried about performance, but it does seem to be working. d98b2bf4e76f86531419dd40d6025ad4ef23a856
thanks again! In terms of performance the base URL would be set only once on window open, so it should hopefully not be too bad... by the way, if you don't mind the slight offtopic, have you considered yuin/goldmark
for the markdown parser? It seems fairly actively developed and it can return an error which might help with the markdown preview stopping occasionally while editing (if it returns an error you would not update the preview, as opposed to now where it always updates).
Thanks for the quick response! I'll try to implement in this approach.
By the way, thanks for the introduction of the markdown parser. I hadn't seen of this one. I'm also aware of the bug that causes updates to stop while editing, but I haven't found a way to fix it. I'll take a look at the parser you introduced me.