Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ§‘πŸ»β€πŸ”¬ Citations & bibliography #161

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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.

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.

None yet

2 participants