Package: jupyterlab-citation-manager
jupyterlab-citation-managerStatus: Work In Progress. Not ready for production environments, may contains bugs.
Feedback on any aspect of this extension is welcome.Citation Manager for JupyterLab:enables adding citations to Jupyter notebooks in Markdown cells,keeps the bibliography in sync with the citations in the document,supports thousands of citation styles,offers a way to efficiently search through your collection of references,integrates with the Zotero® service (Connector for Zotero) by default,is modular in design, allowing for integration of other reference managers in the future.The data of each reference (a.k.a.citable item) is stored in the notebook metadata,
while a mapping between citation ID and the citable items is stored in the cell metadata.storing full data of each citable item in the notebook enables:collaboration between multiple users with separate Zotero collections,retaining the data for citation which got removed from private collection.storing mapping between citation and citable items in the cell metadata allows to copy cells between notebooks.UsageAuthenticate with ZoteroTo enable you to access your reference list you will need to obtain an access API keyfrom your Zotero account.
The most basic, read-only key is sufficient (and recommended). The key will be stored in your settings, so you will only need to enter it once.Insert citationInsert citation by clicking on the insert citation button in the toolbar of your notebook () or pressingAlt+C(hint: shortcut are customizable in Advanced Settings Editor).
Start typing to filter references by title, authors or year.Insert bibliographyInsert bibliography by clicking on the () or pressingAlt+B.Change styleTo change the citation style go to the sidebar () and click on () or pressAlt+S.
Only a subset of generic styles will be shown initially; start typing a name to find more specialised styles.Synchronise referencesTo synchronise your collection of references go to the sidebar () and click on () or pressAlt+U.
Updating can take a few seconds; a progress bar will appear on the status bar to keep you updated (if you have it enabled).Explore your collectionTo get the details on references in your collections without leaving JupyterLab open the sidebar (),
and start typing to find item of interest. You will be able to preview the abstract, check metadata and even
open the article inside JupyterLab (or in a new browser tab - depending on your preference).References with citations in the current document will be show on top when opening the explorer
and enable a quick preview of citation context and navigation to the relevant place in the document
(by clicking on the citation context).Auto-migrate existing citationsWhen opening a notebook, the extension will automatically detect citations in the following formats:cite2c, e.g.<cite data-cite="itemID"></cite>with associated notebook-level metadata,DOI-links, e.g.[(Krassowski et al, 2021)](https://doi.org/10.3389/fcell.2021.626821)(the parentheses in the link label are used as an indicator distinguishing citations from non-citation DOI links)and ask for your permission to migrate them to Citation Manager format.
Only citations inside of markdown cells will be detected.The migrated citations are stored separately from the citations from other providers (such as Zotero),
unless an exact match for given ID, DOI, URL or title and list of authors is found among items available
from reference providers (like Zotero), in which case the item from the provider is used.Exporting to LaTeXCitation Manager supports LaTeX as one of the output formats. For now the citations are embedded as plain-text,
while the bibliography uses semanticthebibliographyLaTeX environment.
To configure notebook to export citations to LaTeX:Go toAdvanced Settings Editor->Citation Managerand change the defaultoutputFormattolatex.Insert bibliography in a cell, but instead of usingMarkdowncell, useRawcellOpenProperty Inspectorsidebar and changeRaw NBConvert FormattoLaTeX(you need to have theRawcell selected for the dropdown to appear)FromFilemenu selectSave and Export Notebook As…and chooseLaTeXCompile the resulting.texto desired output such as PDF with preferred tool (e.g.pdflatexon Linux)RequirementsJupyterLab >= 3.3Modern browser (with ES 2019 support, e.g. Firefox 64+, or Chrome 73+)Zotero accountInstallTo install the extension, execute:pipinstalljupyterlab-citation-managerUninstallTo remove the extension, execute:pipuninstalljupyterlab-citation-managerAdvanced UsageCitation clustersThis extension enables creation of citation clusters, this is a group of citations that are rendered together,
following the chosen citation style. You can create a citation cluster manually by editing cell metadata.Support for creation and edition of citation cluster from the graphical interface is planned.Citation stylesThis extension includes thousands citation styles form theofficial repositoryofCitation Language Styles(CSL) project.If you want to add a custom citation style, you can do so by placing a.cslfile incsl-stylesfolder in one of thedatalocations as returned by:jupyter--pathsThe.cslfile should follow CSL v1.0.1 specification (seeofficial CSL specification).ExampleIfjupyter --pathslooks like:config:
    /home/your_name/.jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/your_name/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/your_name/.local/share/jupyter/runtimeand you want to add your modified version of APA style, you would putmy-custom-apa.cslin/home/your_name/.local/share/jupyter/csl-styles(you will need to create this folder), so that the final structure looks similar to:/home/your_name/.local/share/jupyter
├── csl-styles
│   └── my-custom-apa.csl
├── nbsignatures.db
├── notebook_secret
└── runtimeContributingDevelopment installNote: You will need NodeJS to build the extension package.Thejlpmcommand is JupyterLab's pinned version ofyarnthat is installed with JupyterLab. You may useyarnornpmin lieu ofjlpmbelow.# Clone the repo to your local environment# Change directory to the jupyterlab-citation-manager directory# Fetch build requirementsjlpmrunbootstrap# Install package in development modepipinstall-e.# Link your development version of the extension with JupyterLabjupyterlabextensiondevelop.--overwrite# Rebuild extension Typescript source after making changesjlpmrunbuildYou can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.# Watch the source directory in one terminal, automatically rebuilding when neededjlpmrunwatch# Run JupyterLab in another terminaljupyterlabWith the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).By default, thejlpm run buildcommand generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:jupyterlabbuild--minimize=FalseDevelopment uninstallpipuninstalljupyterlab-citation-managerIn development mode, you will also need to remove the symlink created byjupyter labextension developcommand. To find its location, you can runjupyter labextension listto figure out where thelabextensionsfolder is located. Then you can remove the symlink namedjupyterlab-citation-managerwithin that folder.Updating citation stylesThe citation styles are retrieved from the CSL repository using git submodules
and reside in thejupyterlab-citation-datarepository.You can update the submodule to fetch the most recent citation styles:# fetch the latest styles from the currently tracked CSL version branchgitsubmoduleupdatecsl-styles# store the information about the most recent commit in version controlgitcommitcsl-stylesTo update the version branch:# replace v1.0.1 with the version to trackgitsubmoduleset-branch--branchv1.0.1csl-styles
gitcommitcsl-stylesLegal notesConnector for ZoteroZotero is a registered trademark of theCorporation for Digital Scholarship;
our extension (Connector for Zotero) is not affiliated with the Corporation in any way.CSL stylesThe CSL styles are contributed by individual authors to theCSL project;
all the styles distributed with this extension come from theCitation Language Stylesand are released under theCreative Commons Attribution-ShareAlike 3.0 Unported license.IconsPlease see thestyle/icons/README.mdfor information on the creators and licences of icons included in the distribution.citeproc-jsjupyterlab-citation-managerusesciteproc-jsto format citations and bibliography text;citeproc-jsis
dual-licenced under CPAL 1.0 (or newer) or AGPLv3 (or newer); in order to allow for the distribution of this extension
with other works the CPAL 1.0 licence was adopted for re-distribution ofcireproc-jstogether with this extension.
The Exhibit A ofciteproc-jsCPAL 1.0 licence is presented below for informational purposes:EXHIBIT A. Common Public Attribution License Version 1.0.
“The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License athttps://opensource.org/license/cpal_1-0/The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
The Original Code is citeproc-js.
The Original Developer is not the Initial Developer and is________. If left blank, the Original Developer is the Initial Developer.
The Initial Developer of the Original Code is Frank Bennett. All portions of the code written by Frank Bennett are Copyright (c) 2009-2015. All Rights Reserved.
Contributor___________.
Alternatively, the contents of this file may be used under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE (the AGPLv3 License), in which case the provisions of AGPLv3 License are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of the AGPLv3 License and not to allow others to use your version of this file under the CPAL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the AGPLv3 License. If you do not delete the provisions above, a recipient may use your version of this file under either the CPAL or the AGPLv3 License.”