Skip to content

Commit c53884a

Browse files
committed
compliance with "prettier"
1 parent 38270d4 commit c53884a

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

src/MySTContentFactory.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { MarkdownCell } from '@jupyterlab/cells';
22
import { NotebookPanel, StaticNotebook } from '@jupyterlab/notebook';
33
import { MySTMarkdownCell } from './MySTMarkdownCell';
4-
import { MySTOptionsProvider, MySTNotebookDefaults } from './myst';
4+
import { MySTNotebookOptions, MySTNotebookDefaults } from './myst';
55

66
export class MySTContentFactory extends NotebookPanel.ContentFactory {
7+
mystOptions: MySTNotebookOptions;
78

8-
mystOptions: MySTOptionsProvider<StaticNotebook>;
9-
10-
constructor(options = {},
11-
mystOptions = new MySTNotebookDefaults() as MySTOptionsProvider<StaticNotebook>) {
9+
constructor(
10+
options = {},
11+
mystOptions = new MySTNotebookDefaults() as MySTNotebookOptions
12+
) {
1213
super(options);
1314
this.mystOptions = mystOptions;
1415
}

src/MySTMarkdownCell.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from '@myst-theme/providers';
1515
import { render } from 'react-dom';
1616
import { useParse } from 'myst-to-react';
17-
import { parseContent, MySTOptionsProvider } from './myst';
17+
import { parseContent, MySTNotebookOptions } from './myst';
1818
import { IMySTMarkdownCell } from './types';
1919
import { linkFactory } from './links';
2020
import { selectAll } from 'unist-util-select';
@@ -31,15 +31,18 @@ export class MySTMarkdownCell
3131
private _doneRendering = new PromiseDelegate<void>();
3232
private _doRendering = false;
3333

34-
mystOptions: MySTOptionsProvider<StaticNotebook>;
34+
mystOptions: MySTNotebookOptions;
3535

3636
myst: {
3737
pre?: GenericParent;
3838
post?: GenericParent;
3939
node?: HTMLDivElement;
4040
} = {};
4141

42-
constructor(options: MarkdownCell.IOptions, mystOptions: MySTOptionsProvider<StaticNotebook>) {
42+
constructor(
43+
options: MarkdownCell.IOptions,
44+
mystOptions: MySTNotebookOptions
45+
) {
4346
super(options);
4447
this.mystOptions = mystOptions;
4548

@@ -67,7 +70,10 @@ export class MySTMarkdownCell
6770
this._doneRendering = new PromiseDelegate<void>();
6871
const notebook = this.parent as StaticNotebook;
6972
this.myst.pre = undefined;
70-
const parseComplete = parseContent(notebook, this.mystOptions.get(notebook));
73+
const parseComplete = parseContent(
74+
notebook,
75+
this.mystOptions.get(notebook)
76+
);
7177
const widget = new Widget({ node: this.myst.node });
7278
widget.addClass('myst');
7379
widget.addClass('jp-MarkdownOutput');

src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import {
1212
NotebookPanel,
1313
NotebookWidgetFactory,
1414
NotebookActions,
15-
Notebook,
16-
StaticNotebook
15+
Notebook
1716
} from '@jupyterlab/notebook';
1817
import { Cell } from '@jupyterlab/cells';
19-
import { MySTOptionsProvider } from './myst';
18+
import { MySTNotebookOptions } from './myst';
2019
import { MySTContentFactory } from './MySTContentFactory';
2120

2221
import { ISessionContextDialogs } from '@jupyterlab/apputils';
@@ -37,7 +36,9 @@ const mystIcon = new LabIcon({
3736
* Extension point for MyST options to be defined given a notebook.
3837
* A null provider results in default parser options appropriate to all notebooks.
3938
*/
40-
export const IMySTNotebookOptions = new Token<MySTOptionsProvider<StaticNotebook>>('jupyterlab-myst:IMySTNotebookOptions');
39+
export const IMySTNotebookOptions = new Token<MySTNotebookOptions>(
40+
'jupyterlab-myst:IMySTNotebookOptions'
41+
);
4142

4243
/**
4344
* The notebook content factory provider.
@@ -48,7 +49,11 @@ const plugin: JupyterFrontEndPlugin<NotebookPanel.IContentFactory> = {
4849
requires: [IEditorServices],
4950
optional: [IMySTNotebookOptions],
5051
autoStart: true,
51-
activate: (app: JupyterFrontEnd, editorServices: IEditorServices, mystOptions: MySTOptionsProvider<StaticNotebook>) => {
52+
activate: (
53+
app: JupyterFrontEnd,
54+
editorServices: IEditorServices,
55+
mystOptions: MySTNotebookOptions
56+
) => {
5257
console.log('JupyterLab extension jupyterlab-myst is activated!');
5358
const editorFactory = editorServices.factoryService.newInlineEditor;
5459
return new MySTContentFactory({ editorFactory }, mystOptions || undefined);

src/myst.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,28 @@ import { internalLinksPlugin } from './links';
3737
import { addCiteChildrenPlugin } from './citations';
3838

3939
export interface MySTOptions {
40-
4140
parserOptions: Partial<AllOptions>;
4241
}
4342

4443
export interface MySTOptionsProvider<Widget> {
45-
4644
get(widget: Widget): MySTOptions;
4745
}
4846

49-
export class MySTNotebookDefaults implements MySTOptionsProvider<StaticNotebook> {
47+
/**
48+
* The interface which must be implemented to customize options for notebooks.
49+
*/
50+
export type MySTNotebookOptions = MySTOptionsProvider<StaticNotebook>;
5051

52+
/**
53+
* Global default myst options for notebooks.
54+
*/
55+
export class MySTNotebookDefaults implements MySTNotebookOptions {
5156
get(notebook: StaticNotebook): MySTOptions {
5257
return {
5358
parserOptions: {
5459
directives: [cardDirective, gridDirective, ...tabDirectives],
55-
roles: [evalRole],
56-
},
60+
roles: [evalRole]
61+
}
5762
};
5863
}
5964
}
@@ -70,7 +75,10 @@ const evalRole: RoleSpec = {
7075
}
7176
};
7277

73-
export function markdownParse(text: string, options: Partial<AllOptions>): Root {
78+
export function markdownParse(
79+
text: string,
80+
options: Partial<AllOptions>
81+
): Root {
7482
const mdast = mystParse(text, options);
7583
// Parsing individually here requires that link and footnote references are contained to the cell
7684
// This is consistent with the current Jupyter markdown renderer

0 commit comments

Comments
 (0)