Hi, I’m studying philosophy, and for a few months now, I’ve been using Obsidian and Zotero. A few days ago, I discovered Zotero Integration and this topic. Thanks to many of you who shared your templates, I was able to create my own:
{#- infer latest annotation Date -#}
{%- macro maxAnnotationsDate() -%}
{%- set tempDate = “” -%}
{%- for a in annotations -%}
{%- set testDate = a.date | format(“YYYY-MM-DD#HH:mm:ss”) -%}
{%- if testDate > tempDate or tempDate == “”-%}
{%- set tempDate = testDate -%}
{%- endif -%}
{%- endfor -%}
{{tempDate}}
{%- endmacro -%}
{%- set colorCategoryToMeaning = {
“yellow”: “Idea principal”,
“red”: “Definición (es)”,
“green”: “Idea secundaria o de contexto”,
“blue”: “Dato historico”,
“purple”: “Parrafo”,
“magenta”: “Refencia a personalidades”,
“orange”: “Obras y producciones”,
“gray”: “Preguntas y referencias”
}-%}
{# lookup Zotero colors in annotations with Category #}
{%- macro getMeaning(colorCategory) -%}
{%- if colorCategory-%}
{{- colorCategoryToMeaning[colorCategory] -}}
{%- else -%}
{{- colorCategoryToMeaning[“yellow”] -}}
{%- endif -%}
{%- endmacro -%}
{#- handle space characters in zotero tags -#}
{%- macro printTags(rawTags) -%}
{%- if rawTags.length > 0 -%}
{% set comma = joiner() %}
{%- for tag in rawTags -%}
{{- comma() }} [[Kant/{{ tag.tag }}|{{ tag.tag }}]]
{%- endfor %}
{%- endif %}
{%- endmacro -%}
{%- set inline_fields = {
“abtract”: abstractNote,
“Zotero”: pdfZoteroLink,
“Bibliografía”: ‘"’ ~ bibliography ~ ‘"’
}
-%}
{%- set frontmatter_fields = {
“title”: ‘"’ ~ (title | replace (‘"’,‘’) or caseTitle | replace (‘"’,‘’)) ~ ‘"’,
“authors”: ‘[’ ~ authors | replace (“;”, “, “) ~ ‘]’,
“editors”: ‘[’ ~ editors | replace (”;”, “, “) ~ ‘]’,
“directors”: ‘[’ ~ directors | replace (”;”, “, “) ~ ‘]’,
“translators”: ‘[’ ~ translators | replace (”;”, “, “) ~ ‘]’,
“podcasters”: ‘[’ ~ podcasters | replace (”;”, “, “) ~ ‘]’,
“scriptwriters”: ‘[’ ~ scriptwriters | replace (”;”, ", “) ~ ‘]’,
“Tags”: allTags | replace (” ", ““) | replace (”,”, " "),
“first-entry”: minAnnotationsDate,
“last-entry”: maxAnnotationsDate,
“year”: date | format(“YYYY”),
“date”: date | format(“YYYY-MM-DD”),
“citekey”: citekey,
“pages”: numPages,
“running-time”: runningTime,
“type”: type,
“class”: itemType,
“language”: language,
“url”: url,
“isbn”: ISBN}
-%}
{# generate field safely -#}
{%- macro generateField(prefix, delimiter, f, p) -%}
{%- if p and p != “[undefined]”-%}
{{prefix}}{{f}}{{delimiter}}{{p}}
{% endif %}
{%- endmacro -%}
{#- generate fields based on Zotero properties -#}
{%- macro generateFields(prefix, delimiter, fields) -%}
{%- for field, property in fields -%}
{%- if property.length > 0 -%}
{{- generateField(prefix, delimiter, field, property) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
aliases: [“{{title}}”{%- if authors and date-%}, "
{%- for author in authors -%}
{{author}}
{%- endfor -%}
{{" (“+date | format(“YYYY”) +”) “}}{{title}}{{caseTitle}}”{%- endif -%}]
{{generateFields(“”,": ",frontmatter_fields) -}}
[!info]- Metadata
{{generateFields(“”,": ",inline_fields) -}}
[!NOTE]- Abstract
{% if abstractNote.length > 0 %}
{{abstractNote}}
{% else -%}
No se encontró abstract disponible.
{% endif -%}
{% if relations.length > 0 -%}
[!note]- Referencias:
{%- for r in relations %}
| [[{{r.title}}]] | PDF |
{%- endfor -%}
{%- else -%}
[!note]- Referencias:
No se encontraron referencias.
{%- endif -%}
{{ “” }}
Anotaciones.
{% persist “annotations” %}
{%- set newAnnotations = annotations | filterby(“date”, “dateafter”, lastImportDate) -%}
{% if newAnnotations.length > 0 %}
Fecha importación nuevas anotaciones: {{importDate | format(“YY-MM-DD | HH:mm”)}}
{%- set noteIndex = 1 -%}
{% for annotation in newAnnotations %}
{% if annotation.type == “note” and annotation.color == “#a28ae5”%}
[!zotero-{{annotation.colorCategory | lower}}] {{getMeaning(annotation.colorCategory | lower)}} n. {{ noteIndex }} {%- set noteIndex = noteIndex + 1 %}
N. {{ loop.index }} {{annotation.type|capitalize}}
{%- else %}
[!zotero-{{annotation.colorCategory | lower}}] {{ getMeaning(annotation.colorCategory | lower) }}
N. {{ loop.index }} {{annotation.type|capitalize}}
{%- endif %}
{%- if annotation.tags.length > 0 %}
- {{printTags(annotation.tags)}}
{%- endif %}
{%- if annotation.annotatedText.length > 0 %}
- {{annotation.annotatedText}}
{%- endif %}
{%- if annotation.imageRelativePath %}
![[{{annotation.imageRelativePath}}|300]]
{%- endif %}
{%- if annotation.desktopURI %}
- (p. {{annotation.pageLabel}})
{%- endif %}
{%- if annotation.comment %}
- {{annotation.comment | replace (“”, “”) | replace (“”, “”) | replace ("- ", ">- ")}}
{%- endif %}
%%(Id: {{ annotation.id }})%%
{% endfor %}
{# {% endfor %} #}
{%- endif -%}
{%- endpersist -%}
This is a Frankenstein template based on the work of Feralflora and others I found. I don’t know programming.
I need your help to take my template to the next level.
I want to identify the annotations between two “Purple” “notes” and, based on those annotations, create a list. I need to filter this list by color category and print it in order between the two “Purple” “notes”.
My Purple notes correspond to each paragraph, and my other annotations are categories of highlights, such as primary, secondary, context, etc. That’s why I want to do this.
Tanks for the help.