patrickdavey / vimwiki_markdown

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

Add support for already formatted markdown links #2

Closed Quantum-cross closed 8 years ago

Quantum-cross commented 8 years ago

If vimwiki/vimwiki#186 is merged, this should ensure compatibility once real markdown links are supported.

I don't really know ruby so make sure I did this right :)

patrickdavey commented 8 years ago

Hi @robcross - thanks for the PR. I will wait until https://github.com/vimwiki/vimwiki/pull/186 is merged before pushing any changes to my gem. I haven't actually looked at vimwiki on github for a while, so nice to see that dev and master are pretty close to eachother again.

If you feel like trying, you could add a test to ensure that your change works the way you want it to (and also, squash the commits to remove the separate one for the puts changes... that said, I'll totally merge it in anyway if you don't feel like it, and thanks heaps for being so proactive and sending the PR.

Finally, I'm away on holiday at the moment, and away hiking quite a bit (10 days at a time) so I may be quite slow to respond.

Thanks again, Patrick

Quantum-cross commented 8 years ago

I never knew about the squash feature. Thanks! I thought my shameful puts would be on display forever...

I don't see where tests should go, and I don't know much ruby like I said so I'll hold off on that.

Relax and enjoy the hike!

Edit: I seemed to make even more commit cruft trying to squash... ... Fixed it!

patrickdavey commented 8 years ago

@robcross I've pulled down the latest version of the vimwiki dev branch which has https://github.com/vimwiki/vimwiki/pull/186 merged in.

One thing I'm struggling a little with is, when to know whether to turn a vimwiki markdown style link [something](something) into what sort of link in the html. At the moment there are only [[something]] style links, so it's easy. However, with the []() style links, those could be to a html page so at the moment the gem just passes those links over. Your suggested fix here adds .html to the end of the link, however, those links may already contain a html (e.g. I might have added a link blah , I need to check, but I think your code here will add another .html on the end? Also, from looking at the PR linked above, the vimwiki links can contain

[link](link)
[link](link.md)

So, it seems to me, that my code will need to check whether the linked file exists or not, and then translate it accordingly. And this is before I'd even read the documentation on vimwiki link styles which can contain things like :local, :file etc. which I'm not attempting to look out for at the moment.

Do you have any thoughts? I'm wondering how vimwiki project itself is thinking of handling it.

patrickdavey commented 8 years ago

Yip, thinking about it, this definitely isn't going to work as it'll be doing this for all markdown links (e.g. it will turn [google](http://www.google.com) into [google](http://www.google.com.html) , so there need to be smarts added to check if the markdown file exists, before rewriting. I will attempt to add this in @robcross

patrickdavey commented 8 years ago

I have pushed a fix for this issue which takes care of relative links, absolute links, file extensions etc. It is released in the 0.2.0 release (now pushed to rubygems) https://github.com/patrickdavey/vimwiki_markdown/releases/tag/v0.2.0 Thanks @robcross for the prompt!