nb icon indicating copy to clipboard operation
nb copied to clipboard

Linking notes

Open 99z opened this issue 3 years ago • 15 comments

A combination of searching and tagging notes allows for notes of similar categories or content to be found. However, it would be convenient to directly link notes, ideally bidirectionally.

Possibly something along the lines of:

$ nb link foo bar
$ nb ls
                                      home
--------------------------------------------------------------------------------
[2] bar
└── [1] foo
[1] foo
└── [2] bar
--------------------------------------------------------------------------------
❯ nb · nb add · nb <url> · nb edit <id> · nb show <id> · nb open <id> · nb list
nb search <query> · nb notebooks add <name> · nb settings · nb help

99z avatar Oct 07 '20 20:10 99z

As an extension to this, it would be nice to be able to include some data about the link (a tag or a string). I know this project isn't a knowledge graph tool, but It seems close to something that I could use as one.

distrill avatar Oct 08 '20 02:10 distrill

Will be like https://eugeneyan.com/writing/note-taking-zettelkasten/ ? I like this idea to link notes.

lestersm avatar Oct 09 '20 00:10 lestersm

I've been using VS Code with a few extensions to do the knowledge graph thing, and I'm thinking that it may pair well with nb.

Of course, not everyone wants to marry their note system to VS Code, so this won't be for everyone...

https://github.com/kortina/vscode-markdown-notes gives 'wiki-link' style links with roll-over previews and back-links. You can also use conventional markdown links.

With https://github.com/tchayen/markdown-links you can visualize your knowledge graph as a graph.

Also, Foam, which kind of ties the above together might be interesting. https://github.com/foambubble/foam/

kastork avatar Oct 09 '20 14:10 kastork

It’s pretty easy to add support for command line tools in this area, and there are certainly a lot of ways this could be explored in nb.

To start, I went ahead and added backlink.nb-plugin (with tests), a plugin that wraps note-link-janitor. After installing note-link-janitor and the plugin, you can use nb backlink to add automatically generated backlinks to all linked notes in the current notebook, or nb example:backlink to perform the operation in the "example" notebook.

xwmx avatar Oct 13 '20 06:10 xwmx

nb now includes support for linking with [[wiki-style links]] and browsing using the terminal or GUI web browser in the latest versions of the git repository. More information: Linking and Browsing

xwmx avatar Feb 10 '21 21:02 xwmx

Right, firstly: thanks for a great tool in nb. Amazing stuff. Really nice.

However, when it comes to this backlink business I am starting to conclude I am stupid or something; I can't get it to work in any way, shape or form.

Firstly, everything is up to date. The backlink plugin is listed as "installed" when I do a nb plugins.

In a notebook folder (named "inbox") I have a test folder called "linktest". The actual "address" for it would be inbox:6/.

In that folder I have two files: testfile1.md (inbox:6/1) and testfile2.md (inbox:6/2)

Both files have a headline with the same name as the files, i.e. # testfile1 and # testfile2. In the content they both use double-square brackets, in theory linking them to each other, like this [[testfile1]] and in the other obviously [[testfile2]].

The backlink plugin absolutely, without fail, will find exactly zero links. Zip. Null. Nada. No matter how I try to either call it, or however much/little content I put in those files. I have tried to modify the headlines (H1) too, removing the space etc, all without luck.

I've tried nb backlink. I've tried nb backlink 6/. I've tried nb 6/ backlink. I've tried nb inbox:backlink. I've tried nb inbox:linktest backlinkand of course also nb backlink inbox:linktest/.

None of it works. It gives me the warnings that it might edit multiple files etc and then "No new links found".

So I figured perhaps the wrapper has a bug, and thus I tried note-link-janitor inbox/linktest. That actually created new content in both files. However, it basically repeats the double-square brackets from the "link", but it doesn't actually create an actual link to the file that refers to it. It literally added this, at the end of the file:

* [[testfile1]]
    * This should be a backlink to [[testfile2]]

I love that it references the file and also the line where the link to it came from (the sub bullet), however for it to actually be a backlink (that works in nb browse 6/2 for example, in markdown, it surely should have looked something like this:

* [testfile1]: testfile1.md "testfile1"

as that would make it a clickable markdown link when browsing it (in any browser, w3m or gui), as opposed to lead to a 404.

Ah well. I feel beaten, but I figured I should mention it in any case, and if any hints could be given to how I should call the nb backlink for files in a subfolder, and for it to actually find something, I would love to know. Thanks. :)

hellquist avatar Sep 14 '21 00:09 hellquist

@hellquist Thanks for the heads up. It’s not just you. The backlink plugin predates the full linking and folder features, and it’s limited to the functionality provided by the underlying JavaScript tool. I’ve been intending to start replacing it and just haven’t gotten to it yet.

xwmx avatar Sep 14 '21 20:09 xwmx

@hellquist Thanks for the heads up. It’s not just you. The backlink plugin predates the full linking and folder features, and it’s limited to the functionality provided by the underlying JavaScript tool. I’ve been intending to start replacing it and just haven’t gotten to it yet.

If I skip the backlink for now, I have a more pressing issue though: links (as in double-square-brackets wiki links) doesn't actually lead to the files linked when doing a nb br 4(the "4" was just an example). If that file contains wiki links to other files, the link is there alright. I can click it. It will without fail lead me to a 404 though. What have I missed?

Like a few others I am trying to combine a couple of tools for my note taking, and I notice that the exact same link in the exact same file works in the other tools (in my case VSCode+Foam and also Obsidian), but it does not work in nb browse (which is, of course, where I most desperately would like it to work as I do a lot of my life in a terminal).

I have both ncat and pandoc installed. I'm on macOS and have installed nb with "everything".

hellquist avatar Sep 18 '21 12:09 hellquist

Can you share an example of a link as you specify it with the brackets and then also the destination URL that displays the 404?

xwmx avatar Sep 18 '21 12:09 xwmx

Can you share an example of a link as you specify it with the brackets and then also the destination URL that displays the 404?

Sure. Well, I have no idea how to see the URL in W3M, but if I do a nb browse 6 -g in my inbox notebook it looks like this:

image

I notice that the hover over the link didn't survive the screenshot, but it basically said the URL that is in the screenshot below.

When I click on that link it looks like this:

image

The actual content of the first file is:

This is another file

This is a link to [[Test file]]

Both files are next to each other in the same folder.

hellquist avatar Sep 18 '21 13:09 hellquist

I notice that if I manually add a ".md" to the URL after last character, it actually loads, i.e. manipulating the URL to be "http://localhost:6789/inbox:Test%20file.md"

hellquist avatar Sep 18 '21 13:09 hellquist

Sorry for spamming, but in the spirit of de-bugging: I also notice that http://localhost:6789/inbox: loads just fine, and lists all the files in the inbox folder. Clicking to the files from there actually works as the URL's then use the index number as the URL, i.e. http://localhost:6789/inbox:6, http://localhost:6789/inbox:2 etc. Basically all URL's with the index number works and no URL's with the named link works, unless I add a ".md" extension to the URL.

hellquist avatar Sep 18 '21 13:09 hellquist

Perfect. Thank you very much for the detailed information. Currently, nb resolves full filenames with extensions. I’ll look into adding extension-less resolution.

xwmx avatar Sep 18 '21 16:09 xwmx

To start, I went ahead and added backlink.nb-plugin (with tests), a plugin that wraps note-link-janitor. After installing note-link-janitor and the plugin, you can use nb backlink to add automatically generated backlinks to all linked notes in the current notebook, or nb example:backlink to perform the operation in the "example" notebook.

What do you think about noteexplorer to be used instead?

gour avatar Oct 08 '21 12:10 gour

Amazing tool!! Been looking for such a tool to organize and manage plaintext notes for a while, and this may be it. Just wondering if bidirectional linking functionalities are working now, as I hope to use nb to replace howm. Thanks.

cilia avatar Jul 11 '22 07:07 cilia