Basic template for tagged highlights when creating a child note from annotation
Hi, just to share here a very basic template to add the tags to the highlights you tagged (only if you did so) when creating a child note from annotations.
Example : let say you highlighted "e=mc2" and used the tags #definition and #equation. And let say you want a result just as similar as the template in Zotero documentation for conditional blockquote, just the tags in addition.
See the first code line in the "Conditionnal" section in https://www.zotero.org/support/note_templates
Add the tag part below:
Note the '#' at the beginning of the paragraph, and the space before the # in the tags join part.
The full template copy-paste ready:
Insert it in the annotations.noteTemplates.highlight in the associated preference field, see documentation if in doubt.
Hope it works for you
Extra
Some posible integration with obsidian: make obsidian recognize all your tags #.
You can also set the above with '#_hgh_' to get sort of a nested tag behavior in your obsidian tagging system. In the example above #_hgh_definition and #_hgh_equation. Edit: Actually, you could use obsidian nested tag syntax directly with '/'. Just write #hgh/in the tag part above. Or copy it from here
Edit2: you may want to do the same for the note you add (post-it without highlight). Then go to annotation.notesTemplates.note (instead of .highlight) and add the same tag part suffix. For the obsidian nested syntax #hgh/ above, here is the full preference :
You can see there is no blockquote here, but set it up as you wish.
This waiting for the coming features from Zotero that should enable us to search for tags in our highlights from the advanced search pane, if I am correct.
Example : let say you highlighted "e=mc2" and used the tags #definition and #equation. And let say you want a result just as similar as the template in Zotero documentation for conditional blockquote, just the tags in addition.
See the first code line in the "Conditionnal" section in https://www.zotero.org/support/note_templates
<blockquote>{{highlight}}</blockquote><p>{{citation}}</p>{{if comment}}<p>{{comment}}</p>{{endif}}
Add the tag part below:
{{if tags}}<p>#{{tags : tags join=' #'}}</p>{{endif}}
Note the '#' at the beginning of the paragraph, and the space before the # in the tags join part.
The full template copy-paste ready:
<blockquote>{{highlight}}</blockquote><p>{{citation}}</p>{{if comment}}<p>{{comment}}</p>{{endif}}{{if tags}}<p>#{{tags : tags join=' #'}}</p>{{endif}}
Insert it in the annotations.noteTemplates.highlight in the associated preference field, see documentation if in doubt.
Hope it works for you
Extra
Some posible integration with obsidian: make obsidian recognize all your tags #.
You can also set the above with '#_hgh_' to get sort of a nested tag behavior in your obsidian tagging system. In the example above #_hgh_definition and #_hgh_equation. Edit: Actually, you could use obsidian nested tag syntax directly with '/'. Just write #hgh/in the tag part above. Or copy it from here
{{if tags}}<p>#hgh/{{tags : tags join=' #hgh/'}}</p>{{endif}}
Edit2: you may want to do the same for the note you add (post-it without highlight). Then go to annotation.notesTemplates.note (instead of .highlight) and add the same tag part suffix. For the obsidian nested syntax #hgh/ above, here is the full preference :
<p>{{citation}} {{comment}}</p>{{if tags}}<p>#hgh/{{tags : tags join=' #hgh/'}}</p>{{endif}}
You can see there is no blockquote here, but set it up as you wish.
This waiting for the coming features from Zotero that should enable us to search for tags in our highlights from the advanced search pane, if I am correct.
I shared my template on that other thread. Thought I'd connect the two here.
Update from may (2 months from now), I still do not use so much of obsidian in my workflow, though I am still working on doing monthly reports of my all notes (single and child) and make it searchable.
I created collections of such notes through saved advanced search...but got lazy with actually doing the export.
Was considering using simple macro from windows 10 to run on weekly, monthly, quarterly schedule. But it needs some set up from obsidian side and for now I can live without it. Plus I would need to know how to set up such macro commands...
Will send pic if and when anything new.
Last note: I was also considering some even simpler workflow with libreoffice and the index feature, but sadly (and for serious technical reason) libreoffice cannot provide a clickable index, which is one of the expected results I am looking for. Timeline plugin from obsidian is also nice but too complex for me now.
Last last, I tried a workflow by creating a dummy-like parent item that take the title of the essay/project I am working on, and then add notes as child item. It may sound stupid but respecting the minimizing clic criteria when doing things with computers, I do not need to switch to other app, either be obsidian or libreoffice, so worth the trying.
thank you very much for posting this interesting code here. I would like to add this kind of functionality to my workflow.
I have been working on some code for the Note Template in order to then further process the extracted pdf highlights in Obsidian. I am currently using some conditional statements depending on the highlight color and would love to add additional tag functionality.
I just don't know how to add tags to individual highlights and comments in the pdf viewer. Can I just add text such as `#tag` to a comment in the pdf?
Thank you very much and many regards!
- A scenario for what you are referring to is a manual entry for every '#tag' you want to enter so yes there is no problem at all. But I understand you are referring to a way to automate this, through templates, syntax, and exports.
- I would recommend to make some test for you to see how it behave.
Some clarifications that comes to my mind as I am reading you.
Places from where you can add tags and comments from the pdf reader:
- 1. from the pen symbol : comment and tag after having highlighted a text ; content attached to text item ; findable back in context by clicking the corresponding link, from a child-note and an exported to obsidian note.
- 2. from the post-it symbol : comment and tag a page ; no special link to a text segment ; AFAIK I couldn't find it back on context and in page by clicks (I just got page number and have to manually go the corresponding page on an additional step)
Places where zotero template can add a prefix:
- 1. pen symbol (highlighted text) ; 1.1tag ; 1.2 comment.
Editable from extensions.zotero.annotations.noteTemplates.highlight in preference pane.
- 2. post-it symbol ; 2.1 tag ; 1.2 comment.
Editable from extensions.zotero.annotations.noteTemplates.note.
As a result, the finest granularity you can get with the corresponding suffix in zotero template (example) for obsidian after-treatment:
- comment from highlight: #hgl/com/
- tag from highlight: #hgl/tag/
- comment from post-it (fleeting) note: #fleet/com/
- tag from post-it (fleeting note): #fleet/tag/
More aggregated level and maybe more friendly mapping:
- just tags, whether coming from highlight or from a flying note. Name it #tag/ ; #zotag/ or even #/ (in the latter case you might get lost if you use # in another contexts).
- assume that a note content is by definition a comment and forget about the 'com/'part
As a recap and as for you case, editing "#tag" in both template should do the work.
Note that for confort you might want to add a '-' or a '_' (#tag- or #tag_). Because the algorithm will concatenate the tag right after the prefix.
Also note that if your tagging system co-evolve with another one, you might want to add a distinction sign when coming from zotero (let it #ztag_ for example).
For a simple paragraph. Note the space for the tag join part. Make sure to copy paste your former template before trying. You can reset templates (r-click then reset in advanced pref corresponding item).
Highlights. From advanced preference edit: extensions.zotero.annotations.noteTemplates.highlight and write
<p>{{highlight}} {{if tags}}#ztag_{{tags : tags join=' #ztag_'}}{{endif}} {{citation}} {{comment}}</p>
Notes. From advanced preference, edit extensions.zotero.annotations.noteTemplates.note and write
<p>{{comment}} {{if tags}}#ztag_{{tags : tags join=' #ztag_'}} {{endif}} {{citation}}</p>
It hasn't been re-tested. I have adapted it from my current templates which are different. Let me know if there are some issues.
Some update might come later.
See that I made some modifications as compared as the templates above : added a "Note:" prefix for comments coming from the flying note field; changed the style with italics and breaking spaces. Also, I permutated the order between comment and quote (comments come before the before the quote).
Thanks for all of this information! I have been playing around with modifying the templates for annotations and notes, as suggested in the Zotero documentation and some threads like this one. One thing I haven't figured out how to do is to change the title of the notes generated from annotations. Right now it just defaults to "Annotations" and the date. However, I would like to change the template for the notes title to something more useful, like the file name or a brief citation. I tried {{citation}} but that didn't work
Does anybody know the variable that I would use in the extensions.zotero.annotations.noteTemplates.title template to do this?
Thanks
P.S. I am really enjoying the new version of Zotero, and it has really gotten back into using it after setting it aside for a few years. Thanks to the developers.
I don't think you can use other variables, and {{citation}} within the title template doesn't work indeed. I think the shortest path to insert citation within note title would be using the default keyboard shortcut ctrl+shift+A on item and paste it on the first line of the note.
There are a bunch of plugins to customize notes, to my knowledge Mdnote and BetterNote could do what you describe, but you'll have to check.