mgmeyers / obsidian-zotero-integration

Insert and import citations, bibliographies, notes, and PDF annotations from Zotero into Obsidian.
GNU General Public License v3.0
1.09k stars 55 forks source link

File basename from attachment.path ? #404

Open notuntoward opened 3 weeks ago

notuntoward commented 3 weeks ago

For crossplatform and shared computer reasons, I would like to modify a zotero integration template so that it extracts an attachment's basename from attatchment.path. For example, I'd like a basename() macro that can be used like this:

{% for attachment in attachments | filterby("path", "endswith", ".pdf") %} | [[basename(attachment.path)|PDF]] {%- endfor %}

I tried to come up with such a macro, but only proved that I don't know nunjucks.

In e.g. python, this would be easy and robust to corner cases. Is there reliable way to do this in nunjucks?