foambubble / foam

A personal knowledge management and sharing system for VSCode
https://foambubble.github.io/
Other
15.5k stars 666 forks source link

Linking with tags #424

Closed lsx7 closed 1 year ago

lsx7 commented 3 years ago

Use case: Every page is also a tag and linking to other pages can be done simply with #tagname. i.e. ctrl+click on #tagname would take you to tagname.md and autocompletion would automatically work.

Could something like that be supported in Foam? It's very simple&fast to use; and some similar tools support this feature, so it may also help with adoption.

riccardoferretti commented 3 years ago

@lsx7 thanks for the suggestion. Linking for the foreseeable future will follow standard md semantics, so either [[wikilinks]] or [regular links](path/to/file.md). The syntax you are proposing is unfortunately not standard md, and will defy one of the major goals of foam, which is to be compatible to with markdown.

There are also some other challenges, e.g. how to support links to filenames that include spaces.

I think you might find interesting to think of it the other way around, which is something somewhat popular in the Foam and other communities: tags as wikilinks. Some people instead of #mytag will write[[mytag]] or [[tags.mytag]]. This would achieve, although with a different syntax, what you are looking for.

For all the reasons above I am gonna close the issue now, feel free to leave other comments if you think I am missing something.

lsx7 commented 3 years ago

Thank you for your fast reply. Maybe I should've make this more clear in the initial post - this feature wouldn't break the existing functionality, just complement it.

Linking for the foreseeable future will follow standard md semantics, so either [[wikilinks]] or [regular links](path/to/file.md). The syntax you are proposing is unfortunately not standard md, and will defy one of the major goals of foam, which is to be compatible to with markdown.

I'm sorry, but can you link to the markdown standard, where it defines [[wikilinks]]? It's been a few years since I've worked on markdown parsers/ASTs, but [[wikilinks]] were definitely were not part of the standard markdown and their use/support was custom and very arbitrary. If that has changed, I'm genuinely interested.

Anyway, back to the topic: for this type of tool, I find [[wikilinks]] syntax useful, especially since it supports piping. Tag links wouldn't change any of that. In fact, basic support for this feature could be trivial: just (optionally) handling ctrl+click on #page (which currently does nothing), to create/go-to page.md.

There are also some other challenges, e.g. how to support links to filenames that include spaces.

This is not a problem, since tags by definition can't include spaces (i.e. they wouldn't be parsed as tags in the first place).

I think you might find interesting to think of it the other way around, which is something somewhat popular in the Foam and other communities: tags as wikilinks. Some people instead of #mytag will write[[mytag]] or [[tags.mytag]]. This would achieve, although with a different syntax, what you are looking for.

Yes, that's basically the core of this idea (since there's only one main concept instead of two, the whole thing is simpler and easier to reason about). The obvious advantage of #mytag over [[mytag]] or [[tags.mytag]] is that it doesn't need extra, custom syntax (since they are tags, it's natural to write them with hash symbols), it's faster to type and there's less visual clutter.

For all the reasons above I am gonna close the issue now, feel free to leave other comments if you think I am missing something.

I think it would be useful to leave this issue open (or creating a thread somewhere else, where users can easily find it) for exploring possible solutions and workarounds for people who will want to organize things this way. Especially since a lot of people have used tools like Roam, which is using wikilinks and tags interchangeably.

riccardoferretti commented 3 years ago

I'm sorry, but can you link to the markdown standard, where it defines [[wikilinks]]?

Technically you are correct, I meant "standard" in a lax way, I believe you'd agree it's the defacto standard in connected wiki-style repos.

handling ctrl+click on #page (which currently does nothing), to create/go-to page.md

The cmd+click functionality is not contributed by Foam itself, but by Markdown Notes, if that is the feature request it might be better to file it there.

I think it would be useful to leave this issue open

Foam is also working on a more comprehensive definition for links (along the lines of Obsidian and Roam), so I am happy to reopen this if it can be helpful there.

lsx7 commented 3 years ago

I'm sorry, but can you link to the markdown standard, where it defines [[wikilinks]]?

Technically you are correct, I meant "standard" in a lax way, I believe you'd agree it's the defacto standard in connected wiki-style repos.

If we're taking about repos which are made to be parsed by github's Gollum, then yes, it's a "standard" they support, but even then, some people prefer to use only standard markdown links to make things future-proof and to stay markdown-compatible. I definitely would be wary of calling wikilinks a markdown standard anywhere in the documentation (even here, it may confuse some people).

handling ctrl+click on #page (which currently does nothing), to create/go-to page.md

The cmd+click functionality is not contributed by Foam itself, but by Markdown Notes, if that is the feature request it might be better to file it there.

OK, thanks, I'll check the vscode-markdown-notes project and maybe file a new issue there. btw. do you plan to integrate some of the core functionality (like handling cmd+click) from vscode-markdown-notes later in the foam itself, or it will stay in a separate, 3rd party project?

riccardoferretti commented 3 years ago

do you plan to integrate some of the core functionality (like handling cmd+click) from vscode-markdown-notes later in the foam itself, or it will stay in a separate, 3rd party project?

That's a good question, Foam initially was mostly a collection of extensions with some glue, but moving forward it will include anything that has to do with the graph model part itself, so that other extensions can build on top of it.

That means that things like link parsing, tags, connections, properties (and maybe something else not at the top of my mind) will live in Foam itself, and drive other features (such as graph dataviz, autocompletion, navigation, placeholder generation, graph analysis, ..).

Other extensions (markdown notes, markdown links, ...) instead of having to do their own parsing/processing, could just leverage the Foam model once. Also other extensions could augment the model it (the closest example of that atm is https://github.com/foambubble/foam/blob/master/docs/features/foam-local-plugins.md). So, think that we have a graph extension that can filter by properties, and we also use another extension that e.g. adds properties to the model based on some traits of a note (e.g. all notes in a certain path are given a specific tag). With Foam those two extensions will be able to work together, and with local plugins you can customize your repo even if you are not a developer.

In the initial phase everything will live in the Foam extension itself, both because the model is in flux and because I don't believe Foam is popular enough to get others to build features we would consider core, but down the line we might split the Foam Model extension from other features.

Let me know if the above makes sense, and feel free to join the Discord group to continue the conversation!

lsx7 commented 3 years ago

Yes, it makes a lot of sense. The way things work now is very limiting and you have very little control over the core/essential things.

In the long term, beside those two extension, it may also be a good idea to split the low-level javascript parsing/manipulations into i.e. foam-core (this project wouldn't have any references to vscode, which would make unit testing and future reusability much easier). (edit: just saw that you have foam/packages/foam-core/ dir, so it's maybe split that way already)

I'm busy with other things at this moment, but I'll take a closer look at the project (and join the Discord) later. So far, I like the project and I think it has a great potential, thank you for creating/maintaining it and being active here.

btw. I created a new feature request here: https://github.com/kortina/vscode-markdown-notes/issues/116 (but they don't seem to be active on github issues recently, so I don't know if I'll get any response).

srid commented 3 years ago

See my thoughts on this idea: https://github.com/svsool/vscode-memo/issues/243#issuecomment-754108857

See also: https://github.com/foambubble/foam/issues/15

AustinTSchaffer commented 3 years ago

Not sure if this helps anyone else, but I wrote a quick and dirty python script that generates a directory of markdown docs that contains links to all other markdown files in my notes repo, based on tags. This was mostly to make my graph look more interesting. The tag-files are highlighted in orange.

This script only handles tags that exist in the markdown headers, but I don't see a reason why it couldn't be extended to include inline tags.

https://github.com/AustinTSchaffer/Notebook/blob/main/_app/tags_to_links.py

https://github.com/AustinTSchaffer/Notebook/tree/main/Tags

image

tv42 commented 2 years ago

After one installs https://marketplace.visualstudio.com/items?itemName=kortina.vscode-markdown-notes, you can "Peek references" etc on tags -- BUT, it doesn't seem to support Foam's Hierarchical tags (https://github.com/foambubble/foam/blob/f1a642604677e6be79be14c24ff82d822e43c4b8/docs/features/tags.md?plain=1#L12).

riccardoferretti commented 2 years ago

Foam and Markdown Notes are not compatible unfortunately (you will see issues around wikilink resolution). Foam already supports "Peek references" for links, it shouldn't be too complex to add that for tags as well