Separate Callouts with dataview lists at the end of the template consolidate the different coloured highlights so that the annotations don’t need to be separated by colour and can be read either in context from the main text or together with other highlights of the same colour from within obsidian.
Hi there, this seems great. Do you happen to know the colour codes for the updated Zotero highlight colours (Magenta, Orange, and Brown)? I reckon these will add to customisation options but have been unable to find their hex code.
I have adopted your template (although without grouping as that results in even worse issues for some reason) because its pretty close to what I intend, but I am encountering issues where callouts do not contain the entire comment if a comment has a list structure:
You see here two sets of notes. The upper one is formatted as a standard list which would be renderable in markdown - item X), the lower one just uses paragraphs and doesn’t use a list syntax (- is missing)
I don’t know why that is the case, nor do I know how to fix it. I’m having enough trouble understanding the nunjucks syntax as is, hence I’m posting here hoping someone has an answer.
I try to use this exact same template and it can’t generate the information like in the template.
The picture shows what the plugin generate.
Can someone please help me?
Here’s my template, inspired by @mgmeyers and @erazlogo. However, I only use callouts for the info and the abstract. The annotations and comments are formatted as a bullet list, where comments are listed in bold before the highlight they belong to, which is indented below and highlighted using ==highlight==. If a highlight has tags, those are listed next to the highlight.
The annotations are grouped by color under different headings.
---
citekey: {{citekey}}
aliases: [{% if shortTitle %}"{{shortTitle | safe}}"{% else %}"{{title | safe}}"{% endif %}]
title: "{{title}}"
authors: {{authors}}
tags: [literature-note, {% for t in tags %}{{t.tag}}{% if not loop.last %}, {% endif %}{% endfor %}]
year: {{date | format("YYYY")}}
publisher: "{{publicationTitle}}"
doi: {{DOI}}
---
# [{{title}}]({{desktopURI}})
> [!info]+
>{% if bibliography %}**Bibliography:** {{bibliography}}{% endif %}
>
>**Page-no:** {% for annotation in annotations %}{% if loop.first %}{{annotation.pageLabel}}{% endif %}{% endfor %}
>
>{% if hashTags %}**Tags:** {{hashTags}}{% endif %}
>
>{%- for attachment in attachments | filterby("path", "endswith", ".pdf") %}**PDF:** [{{attachment.title}}](file:///{{attachment.path | replace(" ", "%20")}}){%- endfor %}
>
>[**Open in Zotero**]({{desktopURI}})
>[**Open DOI**](https://doi.org/{{DOI}})
> [!abstract]-
> {% if abstractNote %}
> {{abstractNote|replace("\n"," ")}}
> {% endif %}
---
## Notes
{% macro heading(color) -%}
{%- if color == "#5fb236" -%}
💡 Main ideas, contributions and conclusions
{%- endif -%}
{%- if color == "#2ea8e5" -%}
❔ Questions
{%- endif -%}
{%- if color == "#ffd400" -%}
⭐ Important
{%- endif -%}
{%- if color == "#a28ae5" -%}
🧩 Definitions and concepts
{%- endif -%}
{%- if color == "#ff6666" -%}
⛔ Weaknesses and caveats
{%- endif -%}
{%- endmacro -%}
{% persist "annotations" %}
{% set annotations = annotations | filterby("date", "dateafter", lastImportDate) -%}
{% if annotations.length > 0 %}
*Imported on {{importDate | format("YYYY-MM-DD HH:mm")}}*
{% for color, annotations in annotations | groupby("color") -%}
### {{heading(color)}}
{%- for annotation in annotations -%}
{%- if annotation.imageRelativePath %}
![[{{annotation.imageRelativePath}}]]
{%- endif %}
{%- if annotation.comment %}
- **{{annotation.comment}}:**
- =={{annotation.annotatedText | nl2br}}== [(p. {{annotation.pageLabel}})](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.pageLabel}}&annotation={{annotation.id}}) {% if annotation.hashTags %}{{annotation.hashTags}}{% endif %}
{%- elif annotation.annotatedText %}
- =={{annotation.annotatedText | nl2br}}== [(p. {{annotation.pageLabel}})](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.pageLabel}}&annotation={{annotation.id}}) {% if annotation.hashTags %}{{annotation.hashTags}}{% endif %}
{%- endif -%}{%- endfor %}
{% endfor -%}
{% endif %}
{% endpersist %}
{{abstractNote|replace("\n"," ")}} The replace filter ensures that the abstract stays within the callout even though it may have linebreaks in Zotero. Structured abstracts with headings tend to cause this issue. The workaround is achieved by replacing linebreaks with a single space.
Thanks! I tried several templates before I found this one which I really like.
However, I have a question. I like the idea of grouping highlights by topic, but I want to try without the grouping. How can I cancel it?
I haven’t tried that myself, but in that case, I would make a copy of the template, and then remove the macro for grouping, and then remove these two lines:
{% for color, annotations in annotations | groupby("color") -%}
### {{heading(color)}} <br>
and the last {% endfor -%}.
I think that should do the trick.
By making a copy, you can easily switch back to the template with grouping if you prefer that.
A neat trick if you want to define comments as tasks while annotating in Zotero is to change the comment line in the template to the following: - {{annotation.comment|replace("todo ","[ ] ")}}:
Then, at the start of a comment which you want Zotero Integration to convert into a task, type todo. Any comment that starts with todo, will have the word todo replaced by square brackets [ ] , which turns it into a task according to markdown syntax, as the comments are already in a bullet list, so it becomes - [ ].
You can use any keyword you want to trigger this behavior, just change the template and workflow accordingly and replace todo with something else.
Note that I had to forgo making the comments bold for this to work. Maybe someone knows a workaround that could achieve both?
Hi, thanks for sharing a fascinating format! I do love it.
But, I am struggling with exchanging the position of annotation and comments.
For now, when I integrate Zotero into obsidian, my comment appears first followed by highlighted texts.
But, I want to make the highlighted texts come first and then my comments appear below since I don’t put comments for every highlighted text.
I just noticed that this template doesn’t grab the “item notes” from zotero (these are the notes that you write in the sidebar, not related to a specific highlights, see attached screenshot, on the right side). Do you know how to grab those as well?
Yeah, I don’t make standalone notes in Zotero, so I left that out. I see someone on Discord already gave you the answer. The only thing you need to do is remove {{formattedAnnotations}} from their solution. That’s what “brought everything”. So the solution is:
{%- if markdownNotes %}
{{markdownNotes}}
{%- endif -%}
This could be answered by using the built-in Data Explorer command that Zotero Integration provides, in combination with the templating guide for Zotero Integration.