Local-file links not working
CompletedI often link to local files (e.g., a note will reference the PDF where I got the underlying information). However, I've been having real trouble linking to those resources with file:// links.
At first, I thought this was because I stupidly have spaces in a lot of paths (e.g., `/Users/username/Dropbox (Personal)/path/to/file`).
However, while trying to figure out what degree of escaping I would need, I realized that I couldn't even get a clickable link to `/Users/username/`.
I realize I may be botching the syntax for local-file links, but I feel like I've looked up and tried everything I can think of.
Here's what I've tried and the result:
```
Lorem ipsum dolor sit amet [file link should go here](file:///Users/username/), consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero enim sed faucibus turpis in eu mi bibendum neque. Turpis massa sed elementum tempus egestas sed sed. Id semper risus in hendrerit gravida rutrum quisque non. Aenean pharetra magna ac placerat vestibulum lectus mauris ultrices eros. Cras semper auctor neque vitae tempus quam pellentesque. In nisl nisi scelerisque eu. Commodo nulla facilisi nullam vehicula ipsum. Volutpat consequat mauris nunc congue. Malesuada nunc vel risus commodo viverra maecenas. Et egestas quis ipsum suspendisse. Ac placerat vestibulum lectus mauris. Diam donec adipiscing tristique risus nec feugiat.
```
and
```
Lorem ipsum dolor sit amet [another test link](/Users/username) consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Libero enim sed faucibus turpis in eu mi bibendum neque. Turpis massa sed elementum tempus egestas sed sed. Id semper risus in hendrerit gravida rutrum quisque non. Aenean pharetra magna ac placerat vestibulum lectus mauris ultrices eros. Cras semper auctor neque vitae tempus quam pellentesque. In nisl nisi scelerisque eu. Commodo nulla facilisi nullam vehicula ipsum. Volutpat consequat mauris nunc congue. Malesuada nunc vel risus commodo viverra maecenas. Et egestas quis ipsum suspendisse. Ac placerat vestibulum lectus mauris. Diam donec adipiscing tristique risus nec feugiat.
```
Result:
- the links appear as links in the nvUltra preview pane, but clicking on them doesn't open the folder in the Finder;
- the links appear as links in Marked, but clicking on them doesn't open the folder in the Finder;
- strangely, clicking on the URL portion in the *editing window* of nvUltra does in fact open the folder in the Finder.
-
It seems like there are a couple of issues here (or perhaps you were just experimenting).
1. You seem to be conflating http links with file links. `[foo](bar)` is an HTTP protocol link, not a file link.
2. File protocol links (`[foo](file:///foo/bar)`) require a handler that is capable of accessing the resource. Web browsers can generally do this. The editor hands the URL off to macOS, which can handle it (assuming it is properly formed).
3. The preview pane is different. For a variety of reasons, the preview pane has to be limited. It cannot navigate outside of the previewed page, so links to other URLs will be sent off to your web browser (e.g. `http://google.com/`). But file links don't work like that, presumably since the browser cannot itself open a file URL and would simply pass it back off to the OS, so they don't seem to work from the preview. I suspect there is nothing I can do to change this behavior, but will keep an eye out.
Ultimately, the preview is just that. A preview. To test full functionality of your HTML output, you will need to try it in a browser.
1 -
Got it. Thanks. What threw me is that it worked in the editor. Is there a format for file links in MultiMarkdown? I guess I was thinking of them as a kind of fully expanded wiki link — just specifying the full path instead of one relative to the file in view.
0 -
File links are handled like any other URL, but you have to include the protocol (e.g. `file:///`), otherwise http will generally be assumed.
WikiLinks are entirely different -- `[[foo]]` is an instruction to nvUltra, **NOT** MultiMarkdown, to treat this as a link to another file within the currently open Notebook/Window. WikiLinks have no meaning as far as MultiMarkdown is concerned.
1
Please sign in to leave a comment.
Comments
3 comments