From c53884a038fe6699e028128bf2f8910b42f61098 Mon Sep 17 00:00:00 2001 From: Tavin Cole Date: Sun, 26 Mar 2023 18:08:19 +0200 Subject: [PATCH] compliance with "prettier" --- src/MySTContentFactory.ts | 11 ++++++----- src/MySTMarkdownCell.tsx | 14 ++++++++++---- src/index.ts | 15 ++++++++++----- src/myst.ts | 20 ++++++++++++++------ 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/MySTContentFactory.ts b/src/MySTContentFactory.ts index 698b607..f62e28a 100644 --- a/src/MySTContentFactory.ts +++ b/src/MySTContentFactory.ts @@ -1,14 +1,15 @@ import { MarkdownCell } from '@jupyterlab/cells'; import { NotebookPanel, StaticNotebook } from '@jupyterlab/notebook'; import { MySTMarkdownCell } from './MySTMarkdownCell'; -import { MySTOptionsProvider, MySTNotebookDefaults } from './myst'; +import { MySTNotebookOptions, MySTNotebookDefaults } from './myst'; export class MySTContentFactory extends NotebookPanel.ContentFactory { + mystOptions: MySTNotebookOptions; - mystOptions: MySTOptionsProvider; - - constructor(options = {}, - mystOptions = new MySTNotebookDefaults() as MySTOptionsProvider) { + constructor( + options = {}, + mystOptions = new MySTNotebookDefaults() as MySTNotebookOptions + ) { super(options); this.mystOptions = mystOptions; } diff --git a/src/MySTMarkdownCell.tsx b/src/MySTMarkdownCell.tsx index 4ff1416..4b18636 100644 --- a/src/MySTMarkdownCell.tsx +++ b/src/MySTMarkdownCell.tsx @@ -14,7 +14,7 @@ import { } from '@myst-theme/providers'; import { render } from 'react-dom'; import { useParse } from 'myst-to-react'; -import { parseContent, MySTOptionsProvider } from './myst'; +import { parseContent, MySTNotebookOptions } from './myst'; import { IMySTMarkdownCell } from './types'; import { linkFactory } from './links'; import { selectAll } from 'unist-util-select'; @@ -31,7 +31,7 @@ export class MySTMarkdownCell private _doneRendering = new PromiseDelegate(); private _doRendering = false; - mystOptions: MySTOptionsProvider; + mystOptions: MySTNotebookOptions; myst: { pre?: GenericParent; @@ -39,7 +39,10 @@ export class MySTMarkdownCell node?: HTMLDivElement; } = {}; - constructor(options: MarkdownCell.IOptions, mystOptions: MySTOptionsProvider) { + constructor( + options: MarkdownCell.IOptions, + mystOptions: MySTNotebookOptions + ) { super(options); this.mystOptions = mystOptions; @@ -67,7 +70,10 @@ export class MySTMarkdownCell this._doneRendering = new PromiseDelegate(); const notebook = this.parent as StaticNotebook; this.myst.pre = undefined; - const parseComplete = parseContent(notebook, this.mystOptions.get(notebook)); + const parseComplete = parseContent( + notebook, + this.mystOptions.get(notebook) + ); const widget = new Widget({ node: this.myst.node }); widget.addClass('myst'); widget.addClass('jp-MarkdownOutput'); diff --git a/src/index.ts b/src/index.ts index 2dd6012..461f35f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,11 +12,10 @@ import { NotebookPanel, NotebookWidgetFactory, NotebookActions, - Notebook, - StaticNotebook + Notebook } from '@jupyterlab/notebook'; import { Cell } from '@jupyterlab/cells'; -import { MySTOptionsProvider } from './myst'; +import { MySTNotebookOptions } from './myst'; import { MySTContentFactory } from './MySTContentFactory'; import { ISessionContextDialogs } from '@jupyterlab/apputils'; @@ -37,7 +36,9 @@ const mystIcon = new LabIcon({ * Extension point for MyST options to be defined given a notebook. * A null provider results in default parser options appropriate to all notebooks. */ -export const IMySTNotebookOptions = new Token>('jupyterlab-myst:IMySTNotebookOptions'); +export const IMySTNotebookOptions = new Token( + 'jupyterlab-myst:IMySTNotebookOptions' +); /** * The notebook content factory provider. @@ -48,7 +49,11 @@ const plugin: JupyterFrontEndPlugin = { requires: [IEditorServices], optional: [IMySTNotebookOptions], autoStart: true, - activate: (app: JupyterFrontEnd, editorServices: IEditorServices, mystOptions: MySTOptionsProvider) => { + activate: ( + app: JupyterFrontEnd, + editorServices: IEditorServices, + mystOptions: MySTNotebookOptions + ) => { console.log('JupyterLab extension jupyterlab-myst is activated!'); const editorFactory = editorServices.factoryService.newInlineEditor; return new MySTContentFactory({ editorFactory }, mystOptions || undefined); diff --git a/src/myst.ts b/src/myst.ts index 4c91a69..6f4ef21 100644 --- a/src/myst.ts +++ b/src/myst.ts @@ -37,23 +37,28 @@ import { internalLinksPlugin } from './links'; import { addCiteChildrenPlugin } from './citations'; export interface MySTOptions { - parserOptions: Partial; } export interface MySTOptionsProvider { - get(widget: Widget): MySTOptions; } -export class MySTNotebookDefaults implements MySTOptionsProvider { +/** + * The interface which must be implemented to customize options for notebooks. + */ +export type MySTNotebookOptions = MySTOptionsProvider; +/** + * Global default myst options for notebooks. + */ +export class MySTNotebookDefaults implements MySTNotebookOptions { get(notebook: StaticNotebook): MySTOptions { return { parserOptions: { directives: [cardDirective, gridDirective, ...tabDirectives], - roles: [evalRole], - }, + roles: [evalRole] + } }; } } @@ -70,7 +75,10 @@ const evalRole: RoleSpec = { } }; -export function markdownParse(text: string, options: Partial): Root { +export function markdownParse( + text: string, + options: Partial +): Root { const mdast = mystParse(text, options); // Parsing individually here requires that link and footnote references are contained to the cell // This is consistent with the current Jupyter markdown renderer