rhysd/Shiba

Allow to link to local `.md` files

Opened this issue ยท 20 comments

Allow user to link markdown file to markdown file. Given a link in file1.md to file2.md when user clicks this link [file2.md](file2.md), auto-load and display file2.md in Shiba.

Again, here is how Markn handle this: minodisk/markn@bf31129

rhysd commented

Nice catch!

I must implement to prevent default file loading and opening the markdown file with <markdown-preview>.

rhysd commented

@xhn35rq

I updated Shiba to 0.3.8 with fixing links to markdown documents. Could you try it?

I'm not able to get it to work using 0.3.8. When I click the link, all I get is the error Can't open: file.md on the command line.

rhysd commented

@xhn35rq

I tested with Shiba directory.

$ cd ./Shiba
$ shiba README.md

Then the README.md was shown in window.
Next, I clicked Easy to install link. The clicked document was shown though watching file was stll README.md so when README.md was updated, it showed README.md preview again.

So I tested Shiba again in my environment in some situations but I could not reproduce the error...
Could you tell me the detail?

Hello! Here is updates on what is working and what is not. Assume we have file1.md file2.md and file three.md

Starting in file1.md there is link to file2.md [file2.md](file2.md) When I click on the link file2.md is loaded by Shiba and it works fine!!

But with file2.md loaded when I edit file2.md Shiba will not see any of the changes. Then if I click on "Reload" Shiba will reload file1.md and if I click the link again it will load the new changes. So Shiba cannot see any changes in files that have been loaded via clicking on links.

Also, if a file has spaces in the name it will not be loaded. In file1.md this link will do nothing if I click it: file three.md

Thanks!!

rhysd commented

@xhn35rq

Thank you for your detailed description! I'll check it later.

Thank you for making such an awesome app ๐Ÿ˜‹

rhysd commented

@xhn35rq

I checked your sequence. I think there are a point to fix and another point not to fix.

1. file1.md -> file2.md works well, but file2.md -> file3.md doesn't work

I think this behavior should be fixed. When we click the link to file3.md in file2.md, it should work as the link to file2.md in file1.md. file3.md -> file4.md, ... are the same.
Thank you for the nice pointing out.

2. Watching directory does not change

I think this is an expected behavior. This is a problem of concept of this app.

The main purpose of clicking link would be the check which ensures the link to be correct. I'm writing something (e.g. file1.md), and click a link (e.g. to file2.md) in the document. But I'll want to continue the original document (file1.md).
I mean clicking link is temporary and I want to go back to the original document. But I may overlook some use cases. Is there any use case to move watching directory on clicking links in document?

Ah ok, I see what you mean. Shiba thinks that clicking a link is temporary.

Is there any use case to move watching directory on clicking links in document?

Is it really moving the watching directory? I thought it was just changing the currently watched file?

Sometimes I create networks of linked Markdown documents as a personal wiki-of-sorts.

If I'm clicking the links between each document, I'd expect Shiba to load each document as needed, and not treat the first document as any different than any other document. Because I often enter and exit the network of interlinked documents from any different direction. And I might want to edit a file in response to seeing it loaded into Shiba, and I'd expect that file to be updated whenever I make a change.

However I can see the benefits of the current behavior. I guess it comes down to how many documents you tend to edit at once.

Maybe there is a way to make "Reload" into a back button? As in, reload last known document, but always watch the currently loaded document for changes.


Also, did you see that if a file has spaces in the name it will not be loaded?

In file1.md this link will do nothing if I click it: [this is file two.md](this is file two.md)

rhysd commented

@xhn35rq

I thought it was just changing the currently watched file?

Yes. Sorry for confusing you.

I understood your use case and I think it is reasonable. So I added a workaround. Clicking with modifier key now changes the watching path.

Though it is possible to watch multiple files which we visited, it requires a lot of code changes because it is necessary to make multiple watchers to watch multiple paths with chokidar.

Also, did you see that if a file has spaces in the name it will not be loaded?

Ah, I don't care about the file name containing spaces because I don't use them for file name. I'll check it later.

Clicking with modifier key now changes the watching path.

๐Ÿ‘ good changes. Now I understand about the difficulty with chokidar. So thank you for making the necessary changes, this is very helpful. ๐Ÿ˜„

Ah, I don't care about the file name containing spaces because I don't use them for file name. I'll check it later.

Yes, there are several reasons why spaces will occur in file names, but perhaps it can be solved by running filenames through an URL-escaping step before working with them? This will ensure converting spaces to %20 before working with them? Just an idea for you.

Thanks again ๐Ÿฐ ๐Ÿถ

rhysd commented

I created space test.md and checked Shiba with the file. It seems to work well. If you encountered some problems with files containing white spaces, could you tell me your environment?
I tested it in Ubuntu 12.04. I'm worried that error may occur in other OS environment.

I'm using Ubuntu 14.04 so it should be the same. I'll update to latest Shiba and test.

rhysd commented

@xhn35rq

Thanks!

When I click on link with spaces in name, nothing happens. When I control-click nothing changes except window title changes to full path of link, with escaped spaces. Given this link: [space test.md](space test.md) when control-clicked the window title changes to Shiba (/home/nic/Desktop/space%20.md)

However I can drag and drop files with spaces, and they open just fine.

rhysd commented

Ah, I see. I'll check again. Thanks!

I think marked doesn't consider about the file whose name contains spaces when it converts markdown document to html document.

thanks!

rhysd commented

I fixed the bug in the latest version! I forgot to unescape the path on watching it.

Brilliant!! This works fantastic now. ๐Ÿ†๐Ÿ†๐Ÿ† Best markdown reader I've used so far. It's starting to remind me of Marked app for Mac OS X which I used to use before moving to Linux.

rhysd commented

@xhn35rq

Thank you for so much cooperation! It was very helpful.