Help with Zotero annotations template

I’m currently trying to customize a Zotero annotation template and have seen a lot of good examples, but I’m still not completely satisfied. I can’t seem to wrap my head around how the code is working and keep getting errors.

I’m currently using this block of code (mostly stolen from different templates found on different forums:

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

When using this i get the error ‘unknown block tag: endfor’

I originally used this:

{% for annotation in annotations %}
	{%- if annotation.annotatedText -%}{{annotation.annotatedText}}"([side {{annotation.page}}](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}})) {%- endif %} 
	{%- if annotation.imageRelativePath -%} ![[{{annotation.imageRelativePath}}]] {%- endif %} {% if annotation.comment %}
-   {{annotation.comment}}
{% endif %}
{% endfor -%}

The only difference is that I want to be able to highlight titles and subtitles in different colours (anything but yellow), and use yellow for normal-text highlighting. This is to organize my highlighting under each topic, by e.g. making everything that’s highlighted with ‘red’ a level 2 or 3 header

As you might have noticed I’m quite new here and couldn’t find any matching topics for this question.

I tweaked this person’s template:

I don’t know this syntax, but when counting blocks with if versus blocks with endif, there is a mismatch 5 vs 4. Since these are within the for block, and before the endfor, it’s not unlikely that the engine is not expecting the endfor and says it’s unknown because there should be another endif before it.

Thank you! Finally managed to fix it, using this as a starting point!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.