Created
March 21, 2023 18:06
-
-
Save tavin/0d73c0c39916285fa305bdf2667c8ec7 to your computer and use it in GitHub Desktop.
sample code for setting mystjs parser options in jupyterlab extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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