Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic tag support #302

Closed
6 tasks
riccardoferretti opened this issue Oct 28, 2020 · 14 comments
Closed
6 tasks

Add basic tag support #302

riccardoferretti opened this issue Oct 28, 2020 · 14 comments
Labels
enhancement New feature or request
Milestone

Comments

@riccardoferretti
Copy link
Collaborator

riccardoferretti commented Oct 28, 2020

Add support for tags in the foam workspace.

Each note would be able to define tags in 2 ways:

  • by having a tags property in YAML
    • syntax for this property will be lose, so all of the following will yield the same result:
      • tags: tag1, tag2
      • tags: tag1 tag2
      • tags: #tag1 tag2
      • tags: [tag1, #tag2]
  • by having #tag anywhere in the file

  • Support defining tags via YAML
  • Support defining tags via #tag
  • Add a new tag panel which lists all the tags in the workspace in alphabetical order
  • Clicking on a tag in the panel will trigger a search for the tag in the workspace
  • Cmd+Clicking on a tag in the text will trigger a search for the tag in the workspace
  • (extra) style tags in text (check interaction with Markdown Notes)
@riccardoferretti riccardoferretti added this to the 0.5.0 milestone Oct 28, 2020
@riccardoferretti riccardoferretti added enhancement New feature or request foam-vscode Foam for VSCode extension in packages/foam-vscode and removed foam-vscode Foam for VSCode extension in packages/foam-vscode labels Oct 28, 2020
@jmg-duarte
Copy link
Member

I was led here by the necessity to move from categories to tags in my work (inspired by Zettelkasten).
I think that the tag should be denoted in the note file itself. Example:

# Super Awesome Title

---
@tags: t1, t2, t3
---

Note description

We can prepend the tags line with a special marker (e.g. @) to declare it as metadata.
This metadata could then be extracted to the foam.json file to create a list (or map to allow descriptions) of tags (furthermore, the janitor could then generate a special file containing all tags).

The metadata symbol could also be configured in foam.json or in the settings.json, in this case is a matter of "what really should be the purpose of foam.json".

Personally, I hate YAML, it's whitespace rules are awkward and hard to debug. I also believe that since Foam already makes plenty use of JSON, we should keep everything in the same format, in the name of simplicity.

@canpolat
Copy link

canpolat commented Nov 1, 2020

I think YAML front-matter is the best place to keep all metadata (including tags) about a note. But using # in front-matter may render the resulting YAML invalid. # is used for comments in YAML and the following line will definitely be invalid YAML (which may cause problems if the user wants to view the file in another editor).

tags: [tag1, #tag2]

Other than that, it would also be great if the tags in YAML front-matter had auto-complete functionality.

@riccardoferretti
Copy link
Collaborator Author

thx for the info @canpolat! I didn't know about that, will review the YAML docs and give an update about the specs for this PR

@riccardoferretti
Copy link
Collaborator Author

this is addressed by #311

@digitalsignalperson
Copy link

digitalsignalperson commented Nov 26, 2020

tags don't seem to be working for me

Have the foam template workspace running with recommended extensions

  • foam for vscode (v0.6.0; v0.7.0 hasn't shown up yet)
  • markdown all in one
  • markdown links
  • markdown notes

throwing down #various tags #allovertheplace and the "tag explorer" stays empty. Same with yaml. Any suggestions?

Code OSS 1.51.1
Linux x64

@jmg-duarte
Copy link
Member

jmg-duarte commented Nov 26, 2020 via email

@digitalsignalperson
Copy link

definitely with the #

e.g.
image

@jmg-duarte
Copy link
Member

To appear in the tag explorer you need to write the tags in the MD frontmatter
Like you have that tags: tag1, the trully odd part is why it doesn't appear, are you using the latest version?

@digitalsignalperson
Copy link

hmm the PR said

  • Support defining tags via YAML
  • Support defining tags via #tag
  • Add a new tag panel which lists all the tags in the workspace in alphabetical order

so I imagined defining tags by #tag would also appear in the panel (at least that's the behavior I'd like; similar behaviour in e.g. Obsidian)

I'm on v0.6.0 and code says all extensions up to date. Caveat this is linux with Code OSS so it's looking at https://open-vsx.org/extension/foam/foam-vscode

@jmg-duarte
Copy link
Member

You're right (reopening the issue)

@riccardoferretti do you have insights on the problem?

@jmg-duarte jmg-duarte reopened this Nov 26, 2020
@riccardoferretti
Copy link
Collaborator Author

I have actually experienced this locally for the first time yesterday.
From a cursory look, I think the problem is in the use of matchAll in the extractTags function, but I am not sure and more investigation is necessary

@riccardoferretti
Copy link
Collaborator Author

I tweaked the parsing code, this fixed it on my machine

#382

tbh, I am still a bit baffled as to why the tests were passing before, but what I have there is the right way to deal with the iterator in any case

@digitalsignalperson
Copy link

I'd be down to test. Any links on how to build/test a vscode extension from github? My googling not helping

@jmg-duarte
Copy link
Member

jmg-duarte commented Nov 27, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants