Skip to content

Instantly share code, notes, and snippets.

@tavin
Created March 21, 2023 18:06
Show Gist options
  • Save tavin/0d73c0c39916285fa305bdf2667c8ec7 to your computer and use it in GitHub Desktop.
Save tavin/0d73c0c39916285fa305bdf2667c8ec7 to your computer and use it in GitHub Desktop.
sample code for setting mystjs parser options in jupyterlab extension
import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
import { IMySTNotebookOptions } from 'jupyterlab-myst';
import { MySTNotebookDefaults } from 'jupyterlab-myst/lib/myst';
import { proofsDirective } from './directives';
export class MyNotebookDefaults extends MySTNotebookDefaults {
get(notebook: any) {
const defaults = super.get(notebook);
const directives = defaults.parserOptions.directives || [];
defaults.parserOptions.directives = [...directives, proofsDirective];
return defaults;
}
}
const plugin: JupyterFrontEndPlugin<MyNotebookDefaults> = {
id: 'monkey:plugin',
autoStart: true,
provides: IMySTNotebookOptions,
activate: (app: JupyterFrontEnd) => {
console.log('JupyterLab extension monkey is activated!');
return new MyNotebookDefaults();
}
};
export default plugin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment