Hello everyone! Figured I would share my template after I spent maybe a little toooooo long on it! Shout out to @Feralflora @Qwxlea @apfelstrudelig as I mainly referenced their templates as a jumping off point.
Template:
---
aliases:
- {{title | upper}}
- "@{{citekey}}"
year: {{date | format("YYYY")}}
related:
{%- for r in relations %}
- {{r.citekey}}
{%- endfor %}
---
{#- This is the order in which the annotations are ordered -#}
{%-
set categoryHeading = {
"yellow": "Summary, Definitions, Concepts",
"red": "Purpose, Hypothesis, Aim, Conclusion",
"green": "Methodology",
"blue": "Results",
"purple": "Connections, Agree, Disagree",
"magenta": "Future Implications & Research Ideas",
"orange": "Misc Thoughts & Info to Follow Up",
"gray": "References to Follow Up"
}
-%}
{%-
set zoteroColors = {
"#ffd400": "yellow",
"#ff6666": "red",
"#5fb236": "green",
"#2ea8e5": "blue",
"#a28ae5": "purple",
"#e56eee": "magenta",
"#f19837": "orange",
"#aaaaaa": "gray"
}
-%}
{%-
set zoteroStrings = {
"sm": "sm",
"df": "&df",
"pr": "!pr",
"am": "!am",
"hp": "!hp",
"cg": "!cg",
"cb": "!cb",
"sb": "$sb",
"pt": "$pt",
"in": "$in",
"ms": "$ms",
"sa": "$sa",
"ot": "$ot",
"rs": "@rs",
"lc": "~lc",
"la": "~la",
"ld": "~ld",
"pc": "~pc",
"pa": "~pa",
"pd": "~pd",
"fi": ";fi",
"ri": ";ri",
"mt": "?mt",
"fu": "?fu",
"rf": "%rf"
}
-%}
{#- handle | characters in zotero strings used in MD -#}
{%- macro formatCell(cellText) -%}
{{ cellText | replace("|","❕")}}
{%- endmacro -%}
{#- Macros for handling annotations -#}
{%- macro formatAnnotation(annotation, calloutString) -%}
{%- if annotation.imageRelativePath -%}
- {{calloutString}} ![[{{annotation.imageRelativePath}}]] [Zotero, p. {{annotation.pageLabel}}](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}}){% if annotation.hashTags %} {{annotation.hashTags}}{% endif %} ^{{annotation.id-}}
{% if annotation.comment.substring(2) | trim | length > 0 %}
- {{annotation.comment.substring(2) | trim}}
{% else %}
{% endif -%}
{%- elif annotation.comment.substring(2, 3) === "-" -%}
- {{calloutString}} {{annotation.annotatedText}}
{%- elif annotation.comment.substring(2, 3) === "+" %} {{annotation.annotatedText}} [Zotero, p. {{annotation.pageLabel}}](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}}){% if annotation.hashTags %} {{annotation.hashTags}}{% endif %} ^{{annotation.id-}}
{% if annotation.comment.substring(3) | trim | length > 0 %}
- {{annotation.comment.substring(3) | trim}}
{% else %}
{% endif -%}
{%- elif annotation.annotatedText -%}
- {{calloutString}} {{annotation.annotatedText}} [Zotero, p. {{annotation.pageLabel}}](zotero://open-pdf/library/items/{{annotation.attachment.itemKey}}?page={{annotation.page}}&annotation={{annotation.id}}){% if annotation.hashTags %} {{annotation.hashTags}}{% endif %} ^{{annotation.id-}}
{% if annotation.comment.substring(2) | trim | length > 0 %}
- {{annotation.comment.substring(2) | trim}}
{% else %}
{% endif -%}
{%- endif -%}
{%- endmacro %}
# {{title}}
> [!info]+ Info [Zotero]({{desktopURI}}) | {%- for attachment in attachments | filterby("path", "endswith", ".pdf") %} [PDF](zotero://open-pdf/library/items/{{attachment.itemKey}}){%- endfor %}{% if DOI %} | [DOI:{{DOI}}](http://doi.org/{{DOI}}){% elif ISBN %} | ISBN: {{ISBN}}{% endif %}{%if url %} | [URL]({{url}}){% endif %}
>
> **Bibiography:** {{bibliography}}
>
> **Authors::** {% for a in creators %} [[{{a.firstName}} {{a.lastName}}]]{% if not loop.last %}, {% endif %}{% endfor %}
>
> **Journal::** {{publicationTitle}}
>
> **Ztags::**{% for t in tags %} [[{{t.tag}}]]{% if not loop.last %}, {% endif %}{% endfor %}
>
> **First-page**: {% for annotation in annotations %}{% if loop.first %}{{annotation.pageLabel}}{% endif %}{% endfor %}
{%- if relations.length > 0 %}
{{ "" }}
> [!summary]+ Related Zotero items ({{ relations.length}}):
>
> | title | Literature Note | Links |
> | --- | --- | --- |
{%- for r in relations %}
> | {{formatCell(r.title)}} | [[{{r.citekey}}]] | [Zotero]({{r.desktopURI}}){%- for rAttachment in r.attachments | filterby("path", "endswith", ".pdf") %} [PDF](zotero://open-pdf/library/items/{{rAttachment.itemKey}}){% endfor %} |
{%- endfor -%}
{{ "" }}
{%- endif %}
> [!tldr]+ Non-Zotero Links to This Note
> ```dataview
> TABLE tags as Tags
> FROM [[{{citekey}}]]
> WHERE !contains(file.path, "ZI LiteratureNotes")
> ```
> [!abstract]-{% if abstractNote %}
> {{abstractNote | striptags(true) | replace("BACKGROUND:","**BACKGROUND:**") | replace("CONCLUSIONS:","**CONCLUSIONS:**") | replace("CONCLUSION:","**CONCLUSION:**") | replace("DESIGN:", "**DESIGN:**") | replace("EXPOSURES:","**EXPOSURES:**") | replace("IMPORTANCE:","**IMPORTANCE:**") | replace("INTERVENTIONS:","**INTERVENTIONS:**") | replace("INTRODUCTION:","**INTRODUCTION:**") | replace("METHODS:","**METHODS:**") | replace("OBJECTIVE:", "**OBJECTIVE:**") | replace("PARTICIPANTS:","**PARTICIPANTS:**") | replace("PURPOSE:","**PURPOSE:**") | replace("RECOMMENDATIONS:","**RECOMMENDATIONS:**") | replace("RESULTS:","**RESULTS**:") | replace("SETTING:","**SETTING:**") | replace("CONCLUSIONS AND RELEVANCE:","**CONCLUSIONS AND RELEVANCE:**") | replace("DATA SOURCES:","**DATA SOURCES:**") | replace("DESIGN, SETTING, AND PARTICIPANTS:","**DESIGN, SETTING, AND PARTICIPANTS:**") | replace("ELIGIBILITY CRITERIA:","**ELIGIBILITY CRITERIA:**") | replace("ELIGIBILITY CRITERIA FOR SELECTING STUDIES:","**ELIGIBILITY CRITERIA FOR SELECTING STUDIES:**") | replace("MAIN OUTCOME MEASURES:","**MAIN OUTCOME MEASURES:**") | replace("MAIN OUTCOMES AND MEASURES:","**MAIN OUTCOMES AND MEASURES:**") | replace("PROCESS AND EVIDENCE SYNTHESIS:","**PROCESS AND EVIDENCE SYNTHESIS:**") | replace("RESEARCH DESIGN AND METHODS:","**RESEARCH DESIGN AND METHODS:**") | replace("STUDY DESIGN AND SETTING:","**STUDY DESIGN AND SETTING:**")}}{% endif %}
# Persistent Notes
{% persist "notes" %}
{% endpersist %}
# Annotations (Exported: [[{{exportDate | format("YYYY-MM-DD")}}]])
{% for colorHex, colorCategory in zoteroColors %}
## {{categoryHeading[colorCategory]}}
{% for beginString, calloutString in zoteroStrings %}
{%- for annotation in annotations | filterby("color", "startswith", colorHex) | filterby("comment", "startswith", beginString) %}
{%- if annotation -%}
{%- if annotation.comment.substring(0,2) === "sm" -%}
> [!summary] Summary
> {{annotation.comment.substring(2) | trim}}
> ^{{annotation.id}}
{% else -%}
{{formatAnnotation(annotation, calloutString)}}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{%- endfor -%}
Literature Note in Editing View:
This template was created with the aim of synthesizing a literature matrix from literature notes exported from Zotero Integration. As such, I wanted to have all annotated text, embedded images, and comments appear in a list format, as it is possible to TABLE query list content under sections (headers) using dataview. It was also important for me to have colored highlights be grouped together AND types of information highlighted sorted as well. For example, under the “Methodology” section, it would be important to have all information about subjects together, then information about the study protocol, then about instrumentation used, so on and so forth.
To achieve this, I used the List Callouts plugin (thank you @mgmeyers!) and, after using a for loop to go through the Zotero colors in the order I wanted, use a for loop to go through the callout characters used for List Callouts in the order I wanted as well! To make this work, I comment every annotation I make in Zotero with the callout characters, regardless if I need to make an actual comment or not. Example below:
With every string of callout characters having a length of 2, I then have the template substring the callout characters from the comment and then place them in the beginning of a image or text annotation with a special character appended to the beginning. I do this because I am admittedly quite lazy and don’t want to always be typing the special characters while annotating or even try to remember them. The section of the template I define the callout characters is near the beginning, “zoteroStrings”. List Callout plugin recognizes the characters and then decorates the literature note accordingly.
A novel thing I implemented in the template is the ability to append same-color annotations together, when there is a different-color annotation between them. To exemplify this, refer to the figure below:
As you can see, I started the magenta annotation right at the tail end of page 5, where it continues onto page 6. However, I also wanted to annotate the table at the end of page 5 with a blue highlight (for results). To append the annotations together, I place a “-” sign at the end of the callout characters for the annotation that is cutoff and don’t make any further comments. The next magenta annotation, I place a “+” sign at the end of the callout characters to append the annotated text to the previous magenta annotation, as well as comment whatever else I want. This is how it looks in the literature note:
So far, this works for cut-off annotations of the same color, with a different colored annotation between them and without any annotation between them. It does not work if the between annotation is the same color as the cut-off annotations. So in the above example, if I wanted to highlight the table with magenta, it would not work . Only way I can see solving that is having all image annotations go last or go first by having callout characters for image comments be the same.
Thats pretty much it for the template. There was quite a bit of setting up to do in the List Callout plugin settings, which I am happy to post my settings if people are interested. I figure what people may be more interested in and adapt from this template is
- the procedure of commenting every annotation in zotero with unqiue callout characters so that they can then be sorted in a manner you prefer
- appending same colored cut-off annotations with a different colored annotation between them and without any annotation between them
If you have any questions feel free to holler. Thanks!