mgmeyers / obsidian-zotero-integration

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

Not able to access Annotation #184

Open cferran1 opened 1 year ago

cferran1 commented 1 year ago

I am trying to import annotations from Zotero. I can see them in the Zotero Data explorer, but when I try to write a template that will access them, it does not work. The following code (and many variations of it) come out with nothing.

{%- for annotation in annotations %} {{annotation.annotatedText}} {{annotation.comment}} {%- endfor %}

If I use the same template that I have for importing data (so I can see them in the Data explorer) for either Citation format or Output format it will not work. I am a newbie and I do not understand why the script should be different. The template works for one, so I do not understand why it would not work for the others.

I am also trying to understand what each is meant to do. But that is probably a different issue. I would love to be able to implement what is written in Alexandra Phelan's article but that might be too complex. I will go one step at a time. I am using Windows and the latest version of all the plugins and software.

Any guidance will be appreciated. Thanks.

leminhhien0301 commented 1 year ago

the same issue here. I thought my computer has something wrong with it.

medium-old commented 1 year ago

Hi everyone,

This template integration isn't as easy as it sounds, here is the template I use; where, H4 is converted from highlighter color into a heading. I use it to separate sections in papers.

## Annotations 
{% for annotation in annotations -%}{%- if annotation.annotatedText -%}{% if 'Orange' in annotation.colorCategory %} 
##### {{annotation.annotatedText | escape }}{% else %} 
<mark class="customZot-{% if annotation.color %}{{annotation.colorCategory}} {% endif %}">{{annotation.annotatedText | escape }}</mark> ([{{annotation.page}}](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}}))
{% endif %}{%- endif %} {% if annotation.imageRelativePath %} ![[{{annotation.imageRelativePath}}]] {% endif %}{% if annotation.comment %}
>*{{annotation.comment}}* 
{% endif %}{% endfor -%}

alongside the CSS - which as you can see, can use different color references (you add CSS manually via any codewriter and save into File Explorer, Obsidian->Vault Name->.obsidian->snippits)

.customZot-Yellow { background-color: rgba(255, 229, 0, 0.46) !important;}
.customZot-Green { background-color: rgba(0, 255, 47, 0.46) !important; } 
.customZot-Blue { background-color: #2ea8e5 !important; } 
.customZot-Purple { background-color: #a28ae5 !important; }
.customZot-Red { background-color: rgba(248, 11, 11, 0.46) !important; }
.customZot-Magenta { background-color: rgba(245, 40, 145, 0.46) !important; }
.customZot-Orange { background-color: rgba(255, 153, 0, 0.45) !important; }
.customZot-Gray { background-color: rgba(192, 192, 192, 0.45) !important; }

In Obsidian options -> Appearance -> Turn on CSS snippit

Hope this helps

  1. https://publish.obsidian.md/history-notes/01+Notetaking+for+Historians
  2. https://github.com/mgmeyers/obsidian-zotero-integration/blob/5693ab27316278e11c5f10b6fc0d3501ebedc07a/docs/Templating.md
  3. https://forum.obsidian.md/t/my-zotero-annotation-template-that-works/51662
cferran1 commented 1 year ago

Dear Claudette:

Thank you for your useful reply. Unfortunately, it still does not work. Unfortunately, annotation.annotatedText does not return anything, but your email was very helpful. I started trying all the variables shown in the Zotero Data explorer and see which ones would be available to the "citation Format Template". And authors or Author is not available. So, I wrote:

{% for a in creators %}{{a.lastName}}; {{a.firstName}} {% endfor %}

Of course, I can make that much more sophisticated and I will but for the purpose of this explanation, this should suffice. I also found that variables like pdflink, pdfZoteroLink, dateAddedmoment, formattedAnnotations, markdownNotes, formattedAnnotations, and formattedAnnotationsNew are not available either. And of course, the most important one is the annotations one I cannot get it to work either. The simple code:

{% for a in annotations %} {{a.annotatedText}} {% endfor %}

will not show anything. And I have tried simply to a constant instead of {{a.annotatedText}} and it will not show anything. So am I assuming that annotations is not accessible just like the other variables. But annotations shows in the Zotero Data Explorer

@.***

Thank you.

CF Dr. Carlos Ferran, CMA, CSCA, KM @.*** View my research on: http://ssrn.com/author=2003402 & https://orcid.org/0000-0002-4078-7018

From: Claudette Jazmine @.> Sent: Monday, February 27, 2023 5:41 AM To: mgmeyers/obsidian-zotero-integration @.> Cc: Ferran, Carlos @.>; Author @.> Subject: Re: [mgmeyers/obsidian-zotero-integration] Not able to access Annotation (Issue #184)

You don't often get email from @.**@.>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

Hi everyone,

This template integration isn't as easy as it sounds, here is the template I use; where, H4 is converted from highlighter color into a heading. I use it to separate sections in papers.

Annotations

{% for annotation in annotations -%}{%- if annotation.annotatedText -%}{% if 'Orange' in annotation.colorCategory %}

{{annotation.annotatedText | escape }}{% else %}

{{annotation.annotatedText | escape }} ({{annotation.page}})

{% endif %}{%- endif %} {% if annotation.imageRelativePath %} ![[{{annotation.imageRelativePath}}]] {% endif %}{% if annotation.comment %}

{{annotation.comment}}

{% endif %}{% endfor -%}

alongside the CSS - which as you can see, can use different color references (you add CSS manually via any codewriter and save into File Explorer, Obsidian->Vault Name->.obsidian->snippits)

.customZot-Yellow { background-color: rgba(255, 229, 0, 0.46) !important;}

.customZot-Green { background-color: rgba(0, 255, 47, 0.46) !important; }

.customZot-Blue { background-color: #2ea8e5 !important; }

.customZot-Purple { background-color: #a28ae5 !important; }

.customZot-Red { background-color: rgba(248, 11, 11, 0.46) !important; }

.customZot-Magenta { background-color: rgba(245, 40, 145, 0.46) !important; }

.customZot-Orange { background-color: rgba(255, 153, 0, 0.45) !important; }

.customZot-Gray { background-color: rgba(192, 192, 192, 0.45) !important; }

In Obsidian options -> Appearance -> Turn on CSS snippit

Hope this helps

  1. https://publish.obsidian.md/history-notes/01+Notetaking+for+Historianshttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublish.obsidian.md%2Fhistory-notes%2F01%2BNotetaking%2Bfor%2BHistorians&data=05%7C01%7Ccferran%40govst.edu%7C89d7686b1cf74ba3f9c208db18b77ee8%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638130948628279819%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JznqXZNCwCbZXkQIcz5dz6JWpALl5ajER%2BdjB5E%2BdUw%3D&reserved=0
  2. https://github.com/mgmeyers/obsidian-zotero-integration/blob/5693ab27316278e11c5f10b6fc0d3501ebedc07a/docs/Templating.mdhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmgmeyers%2Fobsidian-zotero-integration%2Fblob%2F5693ab27316278e11c5f10b6fc0d3501ebedc07a%2Fdocs%2FTemplating.md&data=05%7C01%7Ccferran%40govst.edu%7C89d7686b1cf74ba3f9c208db18b77ee8%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638130948628279819%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=uWc%2BGVv9kXl6b0o4uprhQK0jScJmJLm%2FJXPzeYbynMM%3D&reserved=0
  3. https://forum.obsidian.md/t/my-zotero-annotation-template-that-works/51662https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fforum.obsidian.md%2Ft%2Fmy-zotero-annotation-template-that-works%2F51662&data=05%7C01%7Ccferran%40govst.edu%7C89d7686b1cf74ba3f9c208db18b77ee8%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638130948628279819%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=VxN4rnYAyp5hsCJcytZ1LVgdn3RGsrUPGl1ApsGfvXI%3D&reserved=0

- Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmgmeyers%2Fobsidian-zotero-integration%2Fissues%2F184%23issuecomment-1446180232&data=05%7C01%7Ccferran%40govst.edu%7C89d7686b1cf74ba3f9c208db18b77ee8%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638130948628279819%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xnDoYa4wsKrNdBgPeGZcBZBCv%2FO1Tuvy2MFa8Sq2pJ4%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6C57AMHKNJQYPKJWJSQCVLWZSHEVANCNFSM6AAAAAAVGKENWU&data=05%7C01%7Ccferran%40govst.edu%7C89d7686b1cf74ba3f9c208db18b77ee8%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638130948628279819%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=iljcrCkptWfiYparN%2Fz2GfCddONCfprNjgxWkJ73438%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.**@.>>

medium-old commented 1 year ago

@cferran1

Hi Carlos,

This is quite strange. Do you receive an error message when importing? thus, if you can import, is there a new note that is created with your citekey/designated title? Is your template file selected on the Zotero Integration plugin settings?

cferran1 commented 1 year ago

No, I do not get any error messages. I simply do not get anything when trying to access those variables. The variables appear in the Zotero Data Explorer, but they do not seem to be available to be used by the system.

I have been working on this for many more hours than I should, but it puzzles me.

I also downloaded the vault that Elena Razlogova provides at https://publish.obsidian.md/history-notes/, and I ran into exactly the same issue with that one. Just to make sure that I provide all the information. If I run her vault as is, I get a few errors, so I had to update all the Plugins. And then it does not give me any errors, but it simply does not work. So, I am wondering if it is that one of the plugins should not be in the "latest" version but somewhere in the middle. But that is something that I cannot really test. I can see the variables in the Data explorer (including the annotations), but there is no output when exporting the references from Zotero.

Thanks,

CF Dr. Carlos Ferran, CMA, CSCA, KM View my research on: http://ssrn.com/author=2003402 & https://orcid.org/0000-0002-4078-7018

From: Claudette Jazmine @.> Sent: Monday, February 27, 2023 1:44 PM To: mgmeyers/obsidian-zotero-integration @.> Cc: Ferran, Carlos @.>; Mention @.> Subject: Re: [mgmeyers/obsidian-zotero-integration] Not able to access Annotation (Issue #184)

You don't often get email from @.**@.>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

@cferran1https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcferran1&data=05%7C01%7Ccferran%40govst.edu%7C6e2bb74e1304441c246108db18fae98f%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131238161208873%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=l%2B%2Bbo2uSMCyUeEhPmTJFf70OknysRxM%2BaryDrcuyJa4%3D&reserved=0

Hi Carlos,

This is quite strange. Do you receive an error message when importing? thus, if you can import, is there a new note that is created with your citekey/designated title? Is your template file selected on the Zotero Integration plugin settings?

- Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmgmeyers%2Fobsidian-zotero-integration%2Fissues%2F184%23issuecomment-1446961120&data=05%7C01%7Ccferran%40govst.edu%7C6e2bb74e1304441c246108db18fae98f%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131238161208873%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=U8ayQlEzeAx8DDpeYaOS5oRg165z%2F%2FAV0OF9mpQiHKc%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6C57APVTOIDN4KXHSHGR5LWZT7WLANCNFSM6AAAAAAVGKENWU&data=05%7C01%7Ccferran%40govst.edu%7C6e2bb74e1304441c246108db18fae98f%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131238161208873%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Rx3OfvVtFYwSTU7ne9Peb7UDlDP5PhrLBMt2g1Eg%2BBw%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

mgmeyers commented 1 year ago

@cferran1 Do you see the annotations when you preview the import?

Screenshot 2023-02-27 at 12 26 13 PM

Also, when you say,

The following code (and many variations of it) come out with nothing.

What are the contents of the resulting markdown file?

cferran1 commented 1 year ago

Yes, I do.

@.***

That is what I meant when I wrote that the variables pdflink, pdfZoteroLink, dateAddedmoment, formattedAnnotations, markdownNotes, formattedAnnotations, and formattedAnnotationsNew were not available. Those variable show in that screen (along with many others) and I cannot get them, but I can get Bibliography, desktopURI, itemKey, itemType, citationKey, itemID, and uri which are also there.

I cannot figure out why some are available and some are not. I do not see the difference between them.

Thanks for trying to help.

Dr. Carlos Ferran, CMA, CSCA, KM View my research on: http://ssrn.com/author=2003402 & https://orcid.org/0000-0002-4078-7018

From: Matthew Meyers @.> Sent: Monday, February 27, 2023 2:29 PM To: mgmeyers/obsidian-zotero-integration @.> Cc: Ferran, Carlos @.>; Mention @.> Subject: Re: [mgmeyers/obsidian-zotero-integration] Not able to access Annotation (Issue #184)

You don't often get email from @.**@.>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

@cferran1https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcferran1&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=h916Ea9cnc4BAlr3ps0bIlas6V7Bw7jYsSKB24HdP%2Fs%3D&reserved=0 Do you see the annotations when you preview the import?

[Screenshot 2023-02-27 at 12 26 13 PM]https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F2694747%2F221677829-c80605af-0508-4558-9041-9bf42f49f65b.png&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cUn03TxEgjkfNKx%2FEqeoWXl5WnK0uKuRdeWg4VSR2to%3D&reserved=0

- Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmgmeyers%2Fobsidian-zotero-integration%2Fissues%2F184%23issuecomment-1447038700&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=j41AF0P%2F4UeYMvgW375Za3jh3XKPsZ0ahJ3so1%2BaHNI%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6C57APEHWXHZPGWPIV3OI3WZUFBLANCNFSM6AAAAAAVGKENWU&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=IXIBzUIWvoZTWv6oKuZc3kcUSmzThDFNeQaWUQsNUF0%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

cferran1 commented 1 year ago

Also, I forgot to mention that if I use "Zotero Integration: Insert notes into Current document" then it will import them correctly.

BTW, is there any way to see the code or template used for that option? Maybe I can copy that code/template or learn from it, and it would solve my problem. But I have no idea where that code/template is. Would you know that?

Thanks,

CF Dr. Carlos Ferran, CMA, CSCA, KM View my research on: http://ssrn.com/author=2003402 & https://orcid.org/0000-0002-4078-7018

From: Matthew Meyers @.> Sent: Monday, February 27, 2023 2:29 PM To: mgmeyers/obsidian-zotero-integration @.> Cc: Ferran, Carlos @.>; Mention @.> Subject: Re: [mgmeyers/obsidian-zotero-integration] Not able to access Annotation (Issue #184)

You don't often get email from @.**@.>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

@cferran1https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcferran1&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=h916Ea9cnc4BAlr3ps0bIlas6V7Bw7jYsSKB24HdP%2Fs%3D&reserved=0 Do you see the annotations when you preview the import?

[Screenshot 2023-02-27 at 12 26 13 PM]https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F2694747%2F221677829-c80605af-0508-4558-9041-9bf42f49f65b.png&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cUn03TxEgjkfNKx%2FEqeoWXl5WnK0uKuRdeWg4VSR2to%3D&reserved=0

- Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmgmeyers%2Fobsidian-zotero-integration%2Fissues%2F184%23issuecomment-1447038700&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=j41AF0P%2F4UeYMvgW375Za3jh3XKPsZ0ahJ3so1%2BaHNI%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FA6C57APEHWXHZPGWPIV3OI3WZUFBLANCNFSM6AAAAAAVGKENWU&data=05%7C01%7Ccferran%40govst.edu%7C76225a1caad742f103c208db190147e5%7Cb86dab28987f4cada951ce05b68601ab%7C0%7C0%7C638131265538077261%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=IXIBzUIWvoZTWv6oKuZc3kcUSmzThDFNeQaWUQsNUF0%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

mgmeyers commented 6 months ago

I've made some updates that may have fixed this issue. Try updating and see if you still have issues with this.