patrickdavey / vimwiki_markdown

A gem to use for converting vimwiki markdown files to html.
MIT License
144 stars 16 forks source link

Relative links for files are not expanded #25

Closed tfachmann closed 4 years ago

tfachmann commented 4 years ago

I just tumbled across your project and really like it to quickly render markdown files of the vimwiki format to html.

For some reason any relative path to a file will be relative within the html_path instead of pointing to the vimwiki path where the actual image is.


Example: I want to embed foo.gif which is in the same folder as bar.wiki. With vimwiki's syntax I'd do

{{foo.gif}}

which results in

<img src="../../foo.gif" alt="foo_alt_text">

for html_path/bar.html when converting to html. Perfect.

With markdown's syntax

![foo_alt_text][foo.gif]
![foo_alt_text2][file:foo.gif]
![foo_alt_text3][file:/abs/path/to/foo.gif]

the relative path's are not adjusted, as the result in html_path/bar.html will simply be

<img src="foo.gif" alt="foo_alt_text">

Am I missing a point, or are relative paths not supported. Is it something from the side of Vimwiki? Besides, I have a workaround to use symbolic links to a dedicated images folder which works, but the behavior was not as expected.

patrickdavey commented 4 years ago

Glad you found the repo :) There are definitely parts (probably many) of the vimiwiki syntax which aren't supported, looks like {{ .. }} is one of those unsupported ones.

When you publish your repo, you actually push up the entire contents of your vimwiki folder itself?

An important thing to note here is that we use github flavoured markdown which is not quite the same as "vimwiki markdown". It doesn't know anything about file: links etc. You can read the image spec here

I'll leave this issue here for if & when I get time to implement it. If you happen to know ruby (or want to have a shot at it) then it probably just needs another method like this one to be called. If It was me, I'd just do the simplest version which will suit you (and leave off the local and file options ;) What I'm slightly curious about is how it automatically knows to go ../../ and whether that is an option which can be passed in and that needs to be taken account of.

tfachmann commented 4 years ago

Thanks for your fast reply!

In my case I don't publish my repo / wiki, but use it as a rich viewer. Therefore, I write and browse in Vim with vimwiki (using latex math, images, ...) and render it with your application from time to time.

True, I was aiming just for the github flavoured markdown, thus ![alt_text](/url "title")

I don't know anything about ruby but I managed to have a look and could implement it, see the following pull request. It might not be idiomatic ruby code as I am used to lower level languages, but it was fun :)

patrickdavey commented 4 years ago

Closing - fixed in https://github.com/patrickdavey/vimwiki_markdown/commit/32500135b8ea4bfe8c8dad8df8c8cffbf26697fd