Skip to content

Conversation

rowanc1
Copy link
Member

@rowanc1 rowanc1 commented Jun 23, 2023

Working on a first attempt to connect up citations.

citations-in-jupyter

Some things to think about for this PR:

  • figure out some state management for shared components
  • have a bibliography listed at the end of the notebook or article
  • pull out the citation transform, and into some shared library (maybe a new one, because citation-js is big)
  • link up DOIs
  • listen to more than just a single, root bibliography.bib

@rowanc1 rowanc1 added the enhancement New feature or request label Jun 23, 2023
@github-actions
Copy link
Contributor

Binder πŸ‘ˆ Launch a Binder on branch executablebooks/jupyterlab-myst/agoose77/wip-bibliography

Copy link
Member Author

@rowanc1 rowanc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes!

import { IRenderMimeRegistry } from '@jupyterlab/rendermime';

import { notebookCellExecuted } from './actions';
import { mystMarkdownRendererFactory } from './mime';
import { citationRenderers } from './myst';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agoose77 we need some way to share the citation renderer into the various places we use those renderer. I don't think they necessarily need to be "connected" (i.e. an update to a bib file doesn't really need to force a re-render, but the next render should bring in the right citation).

The way we have done this in the CLI is to have a state manager, that is indexed based on file name, and then we combine citation renderers before we render the markdown.

I think this could work, and maybe that works? Curious if you know of a better way to share state between the plugins?

Comment on lines +96 to +100
if (renderer) {
citationRenderers[bibFile] = renderer;
} else {
delete citationRenderers[bibFile];
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the manager changes, we just update the shared state, which is then available next time we render markdown. I don't really think we need to go full: update-the bib when the markdown changes as it could potentially render every single cell.

};
}

export function combineCitationRenderers(renderers: CitationRenderer[]) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of this is copied from the CLI, we need to create a package, share this functionality and delete it here!

activate: (app: JupyterFrontEnd) => {
console.log('Using jupyterlab-myst:bibliography');

const bibFile = 'bibliography.bib';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this only works for a single bib file in the root.

@srprca
Copy link

srprca commented Jul 13, 2024

Hello!

I wanted to try out this preliminary version of citations & bibliography, and so I tried building this extension from this pull request.

When I run pip install -e ".[test]", the build process fails with:

File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 167, in prepare_metadata_for_build_editable
    hook = backend.prepare_metadata_for_build_editable
AttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable'

I Googled for this error, and found the following suggestion: pypa/hatch#1114 (comment)

However, it didn't work for me.

I wonder if this problem is indicative of some mistake on my side...?

Thank you!

@huard
Copy link

huard commented Apr 14, 2025

I just wanted to mention that there is an effort underway including folks from AGU's Notebooks Now!, Jupyter, the IPCC and CMIP to advance support for Complex Citation Objects in notebooks. I suppose the functionality provided by this PR could be very useful.

Per this source:

Complex Citation Object (CCO) – a new type of Digital Object Identifier (DOI) supported by the DOI Registration Agencies that includes, as its primary content, a list of Linked Digital Objects.
Linked Digital Object – the metadata necessary to identify the digital objects that support the research, or scholarly product. This includes data, software, physical samples, images, and videos. This does not include the scholarly literature normally included in the Reference section of a paper.

The idea would be to let notebook authors record citation information for datasets and software, in addition to papers. Citation information would be exported into a Complex Citation Object. Publishing that CCO would assign credit to data and software authors. This is especially valuable when a research objects draw from dozens or hundreds of different datasets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants