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

Make updateTags defer to ExportMDFileHeaderV2 #1025

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

atyshka
Copy link

@atyshka atyshka commented Jul 10, 2024

I would like to propose a change to the updateTags feature added in #1024. I prefer to pull tags from the parent item rather than the note, as well as transform tags to standardize them with kebab case. Here's an example:

${{
  let header = {};
  header.tags = noteItem.parentItem.getTags().map((_t) => _t.tag.replace(" ", "-").toLowerCase());
  header.parent = noteItem.parentItem
    ? noteItem.parentItem.getField("title")
    : "";
  header.collections = (
    await Zotero.Collections.getCollectionsContainingItems([
      (noteItem.parentItem || noteItem).id,
    ])
  ).map((c) => c.name);
  return JSON.stringify(header);
}}$

This change reverts to the old behavior of generating tags in ExportMDFileHeaderV2 but retains the auto-update functionality.

@windingwind
Copy link
Owner

Using the tag of the parent item may not be a good idea, as 1) a note can have no parent item and 2) an item can have multiple notes. Also, it would not be possible to sync the tags set in the markdown file back to the note (which is implemented for #1024 as well).

The best I can think of is to allow the ExportMDFileHeaderV2 to overwrite the tags attribute of the YAML header, but that will also conflict with the two-path syncing of the tags.

@atyshka
Copy link
Author

atyshka commented Jul 10, 2024

I see, I missed the fact that you were syncing tags bidirectionally. The challenge with this plugin is a lot of people use it different ways. I use it as a replacement for Obsidian Zotero Integration or Zotlit, as this markdown sync is more frictionless and less buggy. As such I have a one-to-one relationship between items and notes, so using the parent item is logical and simpler.

Regardless of the parent item preference, I still have the problem that in Zotero a lot of auto-generated tags use spaces as separators, which unfortunately break into word-level tags when importing those into Obsidian. Hence my kebab-case transform. Obviously I see the problem now that such a transform would create for bidirectional syncing. I'd be open to a solution in Zotero for standardizing tags, but I haven't encountered a plugin that does this.

The best I can think of is to allow the ExportMDFileHeaderV2 to overwrite the tags attribute of the YAML header, but that will also conflict with the two-path syncing of the tags.

I only care about one-way syncing so this would be ideal for my use case. I understand if you don't want to do things that way though. You would know better than I how the community uses this plugin, especially for Obsidian integration.

@windingwind
Copy link
Owner

I reverted the change for #1024 and tags are now allowed to be updated by Zotero (156c145)

Supporting bidirectional updates for tags seems to block use cases like yours, so I decided not to have it.

Thanks for the contribution and discussion!

@atyshka
Copy link
Author

atyshka commented Jul 11, 2024

Thanks, that works. However, I still see value in two way sync. My proposal might be to add a setting, not for the plugin as a whole but for the export interface, with a 3-option radio selector: 1. manual tag control in template (1-way), 2. auto tag (2-way) 3. auto tag from parent item (2-way). That seems simple enough but gives people options. Before you reverted #1024 I automated the conversion of my tags to kebab case within Zotero using your tags plugin, so I could now take advantage of 2-way syncing via option 3.

If you like this idea I can contribute it this week, you've already invested plenty of time into this so far. I appreciate the interest in this feature!

@windingwind
Copy link
Owner

Thanks, however, I'm not sure if it's worth to implement. If we allow each note to have a separate control on how to handle their tags, that seems to be too complicated. How do you plan to store these information? I guess we'll need to store that in the sync status pref, and save to the markdown header as well (since we want to be able to recover all syncing relations in a folder from files). Sounds like that's too heavy.

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

Successfully merging this pull request may close these issues.

2 participants