Importing Zotero - using different callouts for annotations

What I’m trying to do

When I import information from Zotero, I have a template that pulls in all relevant information and annotations. I want it to pull in the annotations and sort them by highlight color.

Ex: All highlighted blue sections go together. Then, all red highlighted sections are pulled together, etc.

Within those colored sections, I want it to use different callouts. For the blue sections, I have a callout named Literature-background that I want it to use. For the red sections, I want it to use a callout named Literature-future-research.

Things I have tried

I have a template that I’ve been building off. I got the core information from Danny Hatcher’s Zotero template

I’ve been trying to mess with different if and for statements to get it to work. I don’t know much code at all and my brain is so tired from trying to figure this out.

Here is the code template that is working. It sorts them like I want but doesn’t use the different callout boxes for each section:


---
[General Library]({{uri}}) [Zotero Page]({{desktopURI}}) [PDF]({{pdfZoteroLink}})
tags: {{allTags}}


# Annotations:
{%-
    set zoteroColors = {
        "#2ea8e5": "blue",
        "#5fb236": "green",
        "#a28ae5": "purple",
        "#ff6666": "red",
        "#ffd400": "yellow",
        "#f19837": "orange",
        "#aaaaaa": "grey",
        "#e56eee": "magenta"
    }
-%}

{%-
   set colorHeading = {
		"yellow": "General",
		"green": "Findings",
		"purple": "Purple",
		"red": "Future Research",
		"blue": "Background",
		"orange": "References of Interest",
		"grey": "Grey",
		"magenta": "Methods"
   }
-%}

{%- macro calloutHeader(type) -%}
    {%- switch type -%}
        {%- case "highlight" -%}
        Highlight
        {%- case "image" -%}
        Image
        {%- default -%}
        Note
    {%- endswitch -%}
{%- endmacro %}

{%- set newAnnot = [] -%}
{%- set newAnnotations = [] -%}
{%- set annotations = annotations | filterby("date", "dateafter", lastImportDate) %}

{%- for annot in annotations -%}
    {%- if annot.color in zoteroColors -%}
        {%- set customColor = zoteroColors[annot.color] -%}
    {%- elif annot.colorCategory|lower in colorHeading -%}
    	{%- set customColor = annot.colorCategory|lower -%}
    {%- else -%}
	    {%- set customColor = "other" -%}
    {%- endif -%}
    {%- set newAnnotations = (newAnnotations.push({"annotation": annot, "customColor": customColor}), newAnnotations) -%}
{%- endfor -%}

{%- for color, heading in colorHeading -%}
{%- for entry in newAnnotations | filterby ("customColor", "startswith", color) -%}
{%- set annot = entry.annotation -%}

{%- if entry and loop.first %}
## {{colorHeading[color]}}
{%- endif %}

> [!quote]+

{%- if annot.annotatedText %}
> {{annot.annotatedText}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
> - **{{annot.comment}}**
{%- endif -%}
([Page {{annot.page}}]({{annot.desktopURI}}))

{%- endfor -%}
{%- endfor -%}

Now, here is the one I am trying to change. I’ve been messing with different for and if statements but it keeps telling me it is running into the end of the file unexpectedly.

[General Library]({{uri}}) [Zotero Page]({{desktopURI}}) [PDF]({{pdfZoteroLink}})
tags: {{allTags}}


# Annotations:
{%-
    set zoteroColors = {
        "#2ea8e5": "blue",
        "#5fb236": "green",
        "#a28ae5": "purple",
        "#ff6666": "red",
        "#ffd400": "yellow",
        "#f19837": "orange",
        "#aaaaaa": "grey",
        "#e56eee": "magenta"
    }
-%}

{%-
   set colorHeading = {
		"yellow": "General",
		"green": "Findings",
		"purple": "Purple",
		"red": "Future Research",
		"blue": "Background",
		"orange": "References of Interest",
		"grey": "Grey",
		"magenta": "Methods"
   }
-%}

{%- set newAnnot = [] -%}
{%- set newAnnotations = [] -%}
{%- set annotations = annotations | filterby("date", "dateafter", lastImportDate) %}

{%- for annot in annotations -%}
    {%- if annot.color in zoteroColors -%}
        {%- set customColor = zoteroColors[annot.color] -%}
    {%- elif annot.colorCategory|lower in colorHeading -%}
    	{%- set customColor = annot.colorCategory|lower -%}
    {%- else -%}
	    {%- set customColor = "other" -%}
    {%- endif -%}
    {%- set newAnnotations = (newAnnotations.push({"annotation": annot, "customColor": customColor}), newAnnotations) -%}
{%- endfor -%}

{%- for color, heading in colorHeading -%}
{%- for entry in newAnnotations | filterby ("customColor", "startswith", color) -%}
{%- set annot = entry.annotation -%}

{%- if entry and loop.first %}
## {{colorHeading[color]}}
{%- endif %}

{%- for color in colorHeading %}
	{% if color == "blue" %}
	    {{Literature-background}}
	{% elif color == "green" %}
	    {{Literature-findings}}
	{% elif color == "yellow" %}
	    {{Literature-General}}  
	{% elif color == "red" %}
	    {{Literature-future-research}}  
	{% elif color == "orange" %}
	    {{Literature-references-of-Interest}}     
	{% elif color == "magenta" %}
	    {{Literature-methods}}    
	{% else %}
	    {{quote}}
	{% endif %}
{%- endfor -%}

{%- if annot.annotatedText %}
	{{annot.annotatedText}} {% if annot.hashTags %}{{annot.hashTags}}{% endif -%}
{%- endif %}

{%- if annot.ocrText %}
	{{annot.ocrText}}
{%- endif %}

{%- if annot.comment %}
	 **{{annot.comment}}**
{%- endif -%}

{%- if annot.page %}
	[Page {{annot.page}}]({{annot.desktopURI}})
{%- endif -%}

{%- endfor -%}

If anyone with more experienced could help me out with this, that’d be great!

Ok, here is a slightly edited form of the 2nd command I put in my post. This shows a bit more of what I want. It still keeps giving me an (unknown path) unexpected end of file error and I don’t know why

{%- if entry and loop.first %}
## {{colorHeading[color]}}
{%- endif %}

{% if color == "blue" %}
>[!Literature-Background]+ Background 

{% elif color == "green" %}
>[!Literature-Findings]+ Findings 

{% elif color == "yellow" %}
>[!Literature-general]+ General 

{% elif color == "red" %}
>[!Literature-Future-research]+ Future Research 

{% elif color == "orange" %}
>[!Literature-References-of-Interest]+ References of Interest 

{% elif color == "magenta" %}
>[!Literature-Methods]+ Methods  

{% else %}
>[!quote] 

{% endif %}