Import Zotero annotations with Dendron integration. https://github.com/Mjvolk3/Zendron
Project description
Showcase
Here we show how zendron
enables a writing workflow from within VsCode.
- First we show how you can structure a paper using note references in Dendron.
- Install
zendron
and import references from the relevant Zotero library. - Cite while you write, and view all relevant Zotero metadata, annotations, and comment notes with hover.
- Compile paper to
.docx
,.pdf
, and.html
with Pandoc. - Find relevant papers via VsCode search.
Introduction
- This package was developed for porting Zotero annotations and metadata to markdown. This is made possible with pyzotero. These markdown notes are then brought into a Dendron hierarchy for integration with vault notes. Zendron is designed to be used with Visual Studio Code but is editor agnostic... in theory. The end goal is to get a two way sync between notes in Zotero and notes in Dendron, but this has some difficulties and limitations. For now only a one way sync from Zotero to Dendron is supported.
Install Instructions
- It is recommended to build a virtual environment for installation. I've used conda env during development.
- Install Dendron CLI this is needed for note import into Dendron.
npm install -g @dendronhq/dendron-cli@latest
- Install the zendron
python -m pip install zendron
Zotero Local Setup
- To start you need Better BibTeX for Zotero
- This allows pinning of bibtex keys. A stable bibtex key is necessary for predictable behavior within
zendron.
- This allows pinning of bibtex keys. A stable bibtex key is necessary for predictable behavior within
- Go to
Zotero > Settings... > Advanced > General > Config Editor
- Accept the risks.
- In the Search, type
autoPinDelay
and change the integer value from 0 (default) to 1. Click OK.
Zotero API key
- Visit here to setup a Zotero API key.
- We recommend setting up your Zotero API key with the following settings to allow for full functionality.
- Personal Library
- Allow library access.
- Allow notes access.
- Allow write access.
- Default Group Permissions
- Read/Write
- Personal Library
- This key can then be copy-pasted in the configuration file,
"config.yaml"
. You should add your key to.gitignore
to prevent others from accessing your Zotoero database. If the key is lost you can always generate a new one.
Zotero and File Import Configuration
All zendron configuration is handled in config.yaml. Upon initialization it will show in "config/zendron/config.yaml"
.
library_id : 4932032 # Zotero library ID
library_type : group # [user, group] library
api_key : FoCauOvWMlNdYmpYuY5JplTw # Zotero API key
collection: null # Name of Zotero Collection, null for entire library
item_types: [journalArticle, book, preprint, conferencePaper, report] # List of item types according to [pyzotero](https://pyzotero.readthedocs.io/en/latest/)
local_image_path: /Users/<username>/Zotero/cache # Local path for importing annotated images
dendron_limb: zendron.import # Dendron import limb e.g. zendron.import.paper-title.annotations.md
zotero_comment_title: zendron comment # fixed for now... needed for eventual 2-way sync.
pod_path: zotero_pod # Name of dendron pod, removed after completion of import. We will later add configuration for this to remain. This will allow for non Dendron users to import markdown Zotero notes in a strucutred hierarchy.
library_id
- Integer identifier of library. This is the number that matches the name of a library.- User ID. For a user library it you will see something like
"Your userID for use in API calls is 1234567"
- For group ID visit Zotero Groups, click on your desired group, and copy the id from the URL. For instance I have this library.
"https://www.zotero.org/groups/4932032/zendron/library"
, and 4932032 is thelibrary_id
.
- User ID. For a user library it you will see something like
library_type
:group
for group libraries anduser
for user library.api_key
: Use the API Key obtained from Zotero API KEY.collection
: This can be the name of any collection or subcollection in the specificed library. If there are multiple collections or sub collections with the same name, the import will arbitrarily choose one. To make sure you are importing the desired collection, make sure the name of the collection is unique in the Zotero library. Subcollections of a collection will not be imported, this is by design according to how zotero handles subcollections and collections.item_types
: Zotero item types to import according to pyzotero syntax.local_image_path
: Path to annotated images./Users/<username>/Zotero/cache
is the default path on MacOS. It just needs to end incache
.dendron_limb
: This is the period deliminated hierarchy prefix to all file imports for Dendron, e.g.root.zotero.import.<paper_title>.annotations.md
.pod_path
- pod path for dendron import. Should not need to change. Will likely remove from configuration later so it doesn't get accidentally changed.zotero comment title
- IGNORE FOR NOW. Eventually needed for 2-way sync.
Basic Usage
There are 1 command, and two optionall flags.
zendron
- This command should only be run in the root directory of the workspace.
- This command imports notes according to a defined config.yaml. Once the command is run the first time the user needs to modify their configuration
./conf/zendron/config.yaml
. All required configs are marked with a comment# STARTER CONFIG
upon initialization. - Notes are imported with a
## Time Created
heading. This allows for stable reference from other notes, within the note vault. We autogenerate a*.comments.md
that should be used for taking any additional notes within Dendron. Additional notes taken within the meta data file (notes/zendron.import.<paper-title>.md
), or the*.annotations.md
will be overwritten after runningzendron -rm
orzendron -nc
. All files downstream of.import
except*.comments.md
should be treated as read only. - Upon import, notes and tags are left as stubs. To create these notes run
> Dendron: Doctor
thencreateMissingLinkedNotes
. It is best practice to correct tag warnings before doing this. We warn on malformed tag imports. - After running this command it is best to run
Dendron: Reload Index
from the command palette.
zendron -rm
orzendron -remove
- ⚠️ This command removes imported notes and associated links. This command works by removing all notes downstream to
dendron_limb
, except forcomments.md
. There is some difficulty removing other files created because these are separate from thedendron_limb
. These files includeuser.*.md
, which comes from bibtex keys, andtags.*.md
which come from metadata and annotation tags. For now, we don't remove tags, but we do remove bibex keys (<user.bibtex_key>.md
). - ⚠️I have to say it again, don't put other notes downstream of the zendron limb. They will be deleted. The only protected files are
"*.comments.md"
- ⚠️ This command removes imported notes and associated links. This command works by removing all notes downstream to
zendron -nc
orzendron --no-cache
- This is zendron sync without caching. This good to run if you interrupted your import for some reason and need a fresh clean import. If your zendron notes are misbehaving try this command. It will be slower since there is no caching.
- After running this command it is best to run
Dendron: Reload Index
from the command palette.
- Dendron Pod
- A Dendron Pod is used for import according to
pod_path
in theconfig.yaml
. This dir structure is normally deleted to allow for future importing. If you see it, something is wrong. Create an issue on GitHub, or delete the dir and retry the steps above.
- A Dendron Pod is used for import according to
Miscellaneous
- The
zendron_cache
is used for remove of<user.bibtex_key>.md
. If it is deleted and you run remove, the<user.bibtex_key>.md
will not be removed. In this case you can runzendron
again, then run thezendron remove=true
again. - If there are run that fail, sometimes a
.hydra
with the given configuraiton will be generated in the root dir. This isn't an issue but it contains the API information and should therefore be added to the.gitignore
as a safeguard. In addition these files can be used to inspect the reason for the faiure. __main__.log
is generated after running azendron
, this can also be deleted as you please. It is also useful for inspecting an failures to import.
Issues, Troubleshooting, Pull Requests
- If you are having trouble with startup you can use this Zendron-Test template and try to reproduce your issues here. Simply click on
Use this template
, clone the repo and try to runzendron
here. This will allow for us to catch things we overlooked for different user workspace configuration etc. Once you have tried to reproduce issues here please submit an issue on Zendron linking to your minimal example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zendron-1.3.1.tar.gz
(28.1 kB
view details)
Built Distribution
zendron-1.3.1-py3-none-any.whl
(30.8 kB
view details)
File details
Details for the file zendron-1.3.1.tar.gz
.
File metadata
- Download URL: zendron-1.3.1.tar.gz
- Upload date:
- Size: 28.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b7708f9251f6802c30a70c0716156a62f0dd3dd2bef2f04c2429e6ddf2b7b44 |
|
MD5 | feec72591cde625b72ee696185a2a059 |
|
BLAKE2b-256 | 5690176e6f6f0812d19c61a5b6af7dae5666db300db730178f6cbb34b375a19c |
File details
Details for the file zendron-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: zendron-1.3.1-py3-none-any.whl
- Upload date:
- Size: 30.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 269a06ab28d73d04b1866f847522ecfd58664afb36dc3907c1b1b94c8a76c4fc |
|
MD5 | 04a96cb1235fb9dc5e3837fdbf25ba6e |
|
BLAKE2b-256 | 333b3f8b8829d131ec38e1188b6818b35e13ff12995a40d1e0446bc7902ec5df |