Package: zotero2md
Zotero to MarkdownGenerate Markdown files from Zotero annotations and notes.
With newZotero PDF Reader, all highlights are saved in the Zotero database.
The highlights are NOT saved in the PDF file unless you export the highlights in order to save them.If you annotate your files outside the new Zotero PDF reader, this library will not work with your PDF annotations as those are not retrievable from Zotero API.
In that case, you may want to use zotfile + mdnotes to extract the annotations and convert them into markdown files.This library is for you if you annotate (highlight + note) using the Zotero's PDF reader (including the Zotero iOS)InstallationYou can install the library by runningpipinstallzotero2mdNote: If you do not have pip installed on your system, you can follow the instructionshere.UsageSince we have to retrieve the notes from Zotero API, the minimum requirements are:Zotero API key[Required]: Create a new Zotero Key fromyour Zotero settingsZotero personal or group ID[Required]:Yourpersonal library ID(akauserID) can be foundherenext toYour userID for use in API calls is XXXXXX.If you're using agroup library, you can find the library ID byGo tohttps://www.zotero.org/groups/Click on the interested group.You can find the library ID from the URL link that has format likehttps://www.zotero.org/groups/<group_id>/group_name. The number between/groups/and/group_nameis the libarry ID.Zotero library type[Optional]:"user"(default) if using personal library and"group"if using group library.Note that if you want to retrieve annotations and notes from a group, you should provide the group ID (zotero_library_id=<group_id>) and set the library type to group (zotero_library_type="group").Approach 1 (Recommended)After installing the library, open a Python terminal, and then execute the following:fromzotero2md.zt2mdimportZotero2Markdownzt=Zotero2Markdown(zotero_key="your_zotero_key",zotero_library_id="your_zotero_id",zotero_library_type="user",# "user" (default) or "group"params_filepath="",# [Default values provided bellow] # The path to JSON file containing the custom parameters (See Section Custom Output Parameters).include_annotations=True,# Default: Trueinclude_notes=True,# Default: True)zt.run_all()Just to make sure that all files are created, you can runsave_failed_items_to_txt()to ensure that no file was
was failed to create. If a file or more failed to create, the filename (item title) and the corresponding Zotero
item key will be saved to a txt file.zt.save_failed_items_to_txt("failed_zotero_items.txt")Approach 2For this approach, you need to downloadoutput_to_md.pyscript.
Runpython output_to_md.py -hto get more information about all options.pythonzotero2md/output_to_md.py<zotero_key><zotero_id>For instance, assuming zotero_key=abcd and zotero_id=1234, you can simply run the following:pythonzotero2md/output_to_md.pyabcd1234Custom Output ParametersYou can change default parameters by passing the--config_filepathoption with the path to a
JSON file containing the desired configurations. For instance,pythonzotero2md/generate.py<zotero_key><zotero_id>--config_filepath./sample_params.jsonParametertypedefault valueconvertTagsToInternalLinksbooltruedoNotConvertFollowingTagsToLinkList of strings[ ]includeHighlightDatebooltruehideHighlightDateInPreviewbooltrueAny parameter in the JSON file will override the default setting.
If a parameter is not provided, then the default value will be used.For example, if you don't want to show the highlight date in the output file, you can simply pass
a JSON file with the following content:{"hideHighlightDateInPreview":false}FeaturesGenerate MD files for all annotations and notes saved in ZoteroThe ability to convert Zotero tags to internal links ([[ ]]) used in many bidirectional MD editors.You can even pass certain tags that you don't want to convert to internal links! (usingdoNotConvertFollowingTagsToLinkparameter)Quick noteSince I'm personally using Obsidian as my markdown editor, there are custom parameters to generate MD files that are consistent with Obsidian and I'm planning to add more option there.RoadmapUpdate existing annotations and notesOption to add frontmatter section (particularly useful for Obsidian)More flexibility in styling the output filesRequest a new feature or report a bugFeel free to request a new feature or report a bug in GitHub issuehere.📫 How to reach me: