Help with Dataview query to find the highlight color in a Zotero import for Callout

I would like to have my extracted notes and annotations inserted into Callouts that are the color of the original annotation color. I currently have some code that will set the word Highlight and make it the color of the Zotero highlight. I found this in a comment to the Medium article

An Academic Workflow: Zotero & Obsidian by Alexandra Phelan

{%- macro calloutHeader(type, color) -%}  
{%- if type == "highlight" -%}  
<mark style="background-color: {{color}}">Highlight</mark>  
{%- endif -%}{%- if type == "text" -%}  
Note  
{%- endif -%}  
{%- endmacro -%}{%- set annots = annotations | filterby("date", "dateafter", lastExportDate) -%}  
{%- if annots.length > 0 %}  
### Exported: {{exportDate | format("YYYY-MM-DD h:mm a")}}    {% for annot in annots -%}  
> {{calloutHeader(annot.type, annot.color)}}  
{%- if annot.annotatedText %}  
> {{annot.annotatedText | nl2br}}  
{%- endif -%}  
{%- if annot.imageRelativePath %}  
> ![[{{annot.imageRelativePath}}]]  
{%- endif %}  
> [page {{annot.page}}](file://{{annot.attachment.path | replace(" ", "%20")}}) [[{{annot.date | format("YYYY-MM-DD#h:mm a")}}]]  
{%- if annot.comment %}  
> - {{annot.comment | nl2br}}  
{% endif %}{% endfor -%}  
---etc---
{% endif -%}

The result looks like below which is fine but not quite what I am looking for.

image

What I would like to do instead is to embed all notes with the same annotation color into a Callout box so that all Green highlights are lumped together and the same with other colors given that each color has a specific meaning.

An example, also from the same Medium article shows the idea, and did provide some sample code (both below)

{%- macro calloutHeader(type, color) -%}
{%- if type == "highlight" -%}
<mark style="background-color: {{color}}">Highlight</mark>
{%- endif -%}
{%- if type == "text" -%}
Note
{%- endif -%}
{%- endmacro -%}
{%- set annots = annotations | filterby("date", "dateafter", lastExportDate) -%}
{%- if annots.length > 0 %}
### Exported: {{exportDate | format("YYYY-MM-DD h:mm a")}}
{% for annot in annots -%}
> {{calloutHeader(annot.type, annot.color)}}
{%- if annot.annotatedText %}
> {{annot.annotatedText | nl2br}}
{%- endif -%}
{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}
> [page {{annot.page}}](file://{{annot.attachment.path | replace(" ", "%20")}}) [[{{annot.date | format("YYYY-MM-DD#h:mm a")}}]]
{%- if annot.comment %}
> - {{annot.comment | nl2br}}
{% endif %}
{% endfor -%}
{% endif -%}

The result of the above code is a Callout box where all the annotations are imported and the background color not applied. As shown in the image with various color Callouts, I would like for Green annotations to be limped together with the Callout box title that of the color’s meaning and same for the others.

I am not proficient in macros yet so hoping others here can help.

1 Like

For those who may have same idea or question.

I found a link Notetaking for Historians that lead me to the solution Zotero Integration Import Template

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