Skip to content

Commit

Permalink
Replace the jupytext-md fileType with MyST Markdown, R Markdown and Q…
Browse files Browse the repository at this point in the history
…uarto
  • Loading branch information
mwouts committed Dec 2, 2021
1 parent 002fa06 commit 73ddc83
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ When Jupytext is installed, `.py` and `.md` files have a notebook icon. And you
</details>
<details>
<summary>With a click on the text file in JupyterLab</summary>
To do that, you will need to change the default viewer for text files supported by Jupytext by copy-pasting the following settings in `Document Manager` section:
To do that, you will need to change the default viewer for text notebooks by copy-pasting the following settings (or the subset that matches your use case) in the `Document Manager` section:

```json
{
"defaultViewers": {
"markdown": "Jupytext Notebook",
"jupytext-md": "Jupytext Notebook"
"MyST Markdown": "Jupytext Notebook",
"R Markdown": "Jupytext Notebook",
"Quarto": "Jupytext Notebook",
"julia": "Jupytext Notebook",
"python": "Jupytext Notebook",
"R": "Jupytext Notebook"
}
}
```
Expand Down
7 changes: 6 additions & 1 deletion binder/labconfig/default_setting_overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"@jupyterlab/docmanager-extension:plugin": {
"defaultViewers": {
"markdown": "Jupytext Notebook",
"jupytext-md": "Jupytext Notebook"
"MyST Markdown": "Jupytext Notebook",
"R Markdown": "Jupytext Notebook",
"Quarto": "Jupytext Notebook",
"julia": "Jupytext Notebook",
"python": "Jupytext Notebook",
"R": "Jupytext Notebook"
}
}
}
9 changes: 7 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ When Jupytext is installed, `.py` and `.md` files have a notebook icon. And you
</details>
<details>
<summary>With a click on the text file in JupyterLab</summary>
To do that, you will need to change the default viewer for text files supported by Jupytext by copy-pasting the following settings in `Document Manager` section:
To do that, you will need to change the default viewer for text notebooks by copy-pasting the following settings (or the subset that matches your use case) in the `Document Manager` section:

```json
{
"defaultViewers": {
"markdown": "Jupytext Notebook",
"jupytext-md": "Jupytext Notebook"
"MyST Markdown": "Jupytext Notebook",
"R Markdown": "Jupytext Notebook",
"Quarto": "Jupytext Notebook",
"julia": "Jupytext Notebook",
"python": "Jupytext Notebook",
"R": "Jupytext Notebook"
}
}
```
Expand Down
24 changes: 19 additions & 5 deletions packages/labextension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,19 +425,33 @@ const extension: JupyterFrontEndPlugin<void> = {

// Define file types
app.docRegistry.addFileType({
name: "jupytext-md",
displayName: trans.__("Markdown File"),
name: "MyST Markdown",
displayName: trans.__("MyST Markdown Notebook"),
extensions: [".myst", ".mystnb", ".mnb"],
icon: markdownIcon
});

app.docRegistry.addFileType({
name: "R Markdown",
displayName: trans.__("R Markdown Notebook"),
// Extension file are transformed to lower case...
extensions: [".rmd", ".qmd"],
extensions: [".rmd"],
icon: markdownIcon
});

app.docRegistry.addFileType({
name: "Quarto",
displayName: trans.__("Quarto Notebook"),
extensions: [".qmd"],
icon: markdownIcon
});

// Duplicate notebook factory to apply it on markdown file
// Duplicate notebook factory to apply it on Jupytext notebooks
// Mirror: https://github.com/jupyterlab/jupyterlab/blob/8a8c3752564f37493d4eb6b4c59008027fa83880/packages/notebook-extension/src/index.ts#L860
const factory = new NotebookWidgetFactory({
name: "Jupytext Notebook",
// label: trans.__("Jupytext Notebook"), // will be needed in JupyterLab 4
fileTypes: ["jupytext-md", "markdown", "python"],
fileTypes: ["markdown", "MyST Markdown", "R Markdown", "Quarto", "julia", "python", "R"],
modelName: notebookFactory.modelName ?? "notebook",
preferKernel: notebookFactory.preferKernel ?? true,
canStartKernel: notebookFactory.canStartKernel ?? true,
Expand Down

0 comments on commit 73ddc83

Please sign in to comment.