mgmeyers / obsidian-zotero-integration

Insert and import citations, bibliographies, notes, and PDF annotations from Zotero into Obsidian.
GNU General Public License v3.0
1.09k stars 55 forks source link

[BUG] Persist commands have inconsistent behaviour in the Properties section. #317

Open irm-codebase opened 11 months ago

irm-codebase commented 11 months ago

Hello!

Here is my use-case: I subdivide note metadata into Zotero-specific stuff (zotero tags, title, authors, etc.), and Obsidian stuff (obsidian tags, extra attributes that you can only get by understanding the article like region, economic sector, etc.).

This creates a problem: I may want to re-run a template, updating the Zotero metadata, and keep my Obsidian notes and metadata intact.

The persist command works well enough on the notes side, but it breaks stuff if you put it on the metadata. I managed to "cheat" the problem by just completely ignoring the metadata:

---
{% persist "meta" %}
aliases: ["{{title}}"]
authors: [{{authors}}]
{% if journalAbbreviation %}journal: "{{journalAbbreviation}}"{% endif %}
{% if bookTitle %}book: "{{bookTitle}}"{% endif %}
year: {{date | format ("YYYY")}}
{% if DOI %}DOI: https://doi.org/{{DOI}}{% endif %}
zotero tags: [{{allTags}}]
zotero link: zotero://select/items/@{{citekey}}
zotero type: "{{itemType}}" 
obsidian type: "zotero note"
model:
region:
tags: 
date: {{importDate | format("YYYY-MM-DD")}} {% endpersist %}
---

But if you move {% persist "meta" %} or {% endpersist %} anywhere else, the code will break. This is an Obsidian-side issue that the developers will not fix: https://forum.obsidian.md/t/comments-ignored-in-metadata-attributes/73072/3.

irm-codebase commented 11 months ago

Actually, the issue is much, much worse: Obsidian seems to actively delete any comment text in the properties section if you add a new property or modify it. This means you cannot protect the persist command using # either.

Basically, the persistence of any modifications to the metadata cannot be assured, as of now.

FeralFlora commented 5 months ago

Basically, the persistence of any modifications to the metadata cannot be assured, as of now.

If you use Dataview, I recommend a workaround that entails storing metadata you want to persist in a persistent field in the note content as Dataview inline fields.