PKM-er / obsidian-zotlit

A third-party project that aims to facilitate the integration between Obsidian.md and Zotero, by providing a set of community plugins for both Obsidian and Zotero.
https://zotlit.aidenlx.top
MIT License
589 stars 25 forks source link

Annotation Template and Zotlit's Import Note Feature #299

Open aulline13 opened 6 months ago

aulline13 commented 6 months ago

First of all, thank you for such a great plugin!

I'm trying to configure my zt.annot.eta template, and I've encountered several issues I can't resolve on my own.

I want the template to import notes that I create from annotations and comments in Zotero into Obsidian.

After adding annotations and comments to note in Zotero, they look like this:

image

As can be seen, my Zotero note template processes comments and annotations to get the following result: comments become headings, highlights are put in blockquotes under these headings and are followed by a short citation.

When importing such notes into Obsidian, I generally want to preserve the above formatting, except that I want blockquote signs (>) to be rendered as bullet points (-) and I want to have a zotero link to item page appended to the highlight.

So Ideally it should look like this in Obsidian:

image

I managed to configure the zt.annot.eta template to get the bullet points and the zotero link for annotations. Here is the template:

---
callout: false
---

<%- let pageNumber = it.pageLabel -%>
<%- let annotation = it.textBlock.replace("```zotero-annot", "").replace("```", "").replace("[zotero](", "[p. " + pageNumber + "]("). replace("> ", "- ") -%>
<%_ if (it.comment) { -%>
  <%_= it.comment -%>
<% } %>
<%-= it.imgEmbed _%>
<%-= annotation -%>

However, when I use the template to import note into Obsidian, I encounter several problems:

  1. First, extra blockquotes are added before the highlights, i.e. what I get looks like this:

image

I do not have these extra blockquotes if I simply create a literature note.

  1. Also, it seems like if I add <%= it.comment %> to the template (no matter with or without if statement), my comment gets duplicated, and that's why I did not include it in the above code snippet. It looks like this (by the way, the extra blockquote is also added before the comment):

image

The problem with not including comments into the template is that they will not be rendered at all if I use "Create Literature Note" feature instead of "Import Notes".

  1. I also did not manage to figure out how to include the short citation provided by the Zotero (Author, year, page) in the output.

P.S. The only template that I have changed is the zt-annot.eta. Other templates are set to the default versions (including the zt-annots.eta) P.P.S. I do not program - what I've done so far is based on several templates I've seen on the web, so I might be doing something wrong.