Zotero Integration import template line break issue w/ callout

I’ve been adapting some of the really nice templates in another post in the forum. I’m noticing an issue that happens when a highlighted portion of text has a line break in it. Generally, this is when the highlighted text starts a new paragraph. When an import of the annotation from Zotero goes into Obsidian, the callout behavior breaks: the portion of imported text after the line break is not contained within the callout.

So, what needs to happen, it seems, is for the blank line to be replaced with a > mark so that the paragraph break remains within the callout. But I can’t figure out how to code that.

Here is my template:

---
{% if title %}Title: "{{title}}"{% endif %}
Author: {{creators[0].lastName}}, {{creators[0].firstName}}
{% if publicationTitle %}Publication: "{{publicationTitle}}"{% endif %}
{% if date %}Date: {{date | format("YYYY-MM-DD")}}{% endif %}
citekey: {{citekey}}
subject: {{abstractNote}}
tags: {{allTags}}
MOC: 
---
## {{title}}

| Info     | Data              |
| -------- | ----------------- |
| Citation | {{bibliography}}  |
| Zotero   | {{pdfZoteroLink}} |
| Tags     | {{allTags}}       |

# Annotations


{% for annotation in annotations -%}
>[!Note|{{annotation.color}}]+ 
>{%- if annotation.annotatedText -%}« {{annotation.annotatedText}} » ([{{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 %}

In my case I did it like this:

{% set comment = annotation.comment.replace('\n\n', '\n>\n> ') %}
> {{comment}}

Hope it helps

1 Like

I’m late to the party and hope you have figured it out by now, but in case not, try this:

---
{% if title %}Title: "{{title}}"{% endif %}
Author: {{creators[0].lastName}}, {{creators[0].firstName}}
{% if publicationTitle %}Publication: "{{publicationTitle}}"{% endif %}
{% if date %}Date: {{date | format("YYYY-MM-DD")}}{% endif %}
citekey: {{citekey}}
subject: {{abstractNote}}
tags: {{allTags}}
MOC: 
---
## {{title}}

| Info     | Data              |
| -------- | ----------------- |
| Citation | {{bibliography}}  |
| Zotero   | {{pdfZoteroLink}} |
| Tags     | {{allTags}}       |

# Annotations

{% for annotation in annotations -%}
>[!Note|{{annotation.color}}]+ 
{%- if annotation.annotatedText %}
>{% set highlight = annotation.annotatedText.replace('\n', '\n> ') %}
>« {{highlight}} » ([{{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 %}
>
> ---
>{% set comment = annotation.comment.replace('\n', '\n> ') %}
> {{comment}}
{%- endif %}

{% endfor %}

Replaced line breaks in annotatedText and comment with \n> to keep multiline content inside the callout.

1 Like

Thank you!

1 Like

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