A JupyterLab extension to convert plaintext files to Jupyter notebooks
pip install ptjnb- JupyterLab >= 4.0.0
Select a .py or .md file in the file browser → right-click → Convert to Notebook submenu → pick a parser.
If a .ipynb with the same base name already exists, a confirmation dialog asks before overwriting.
Add plainTextNotebookConfig to jupyter_config.json (or JupyterLite's jupyter-lite.json):
{
"jupyter-config-data": {
"plainTextNotebookConfig": {
"rules": [
{ "dir": "percent", "parser": "parsePy" },
{ "dir": "sphinx_gallery", "parser": "parseSphinxGallery" },
{ "dir": "markdown", "parser": "parseClassicMd" },
{ "dir": "myst", "parser": "parseMystMd" }
]
}
}
}Each rule watches a directory and converts matching files on JupyterLab startup (skips files that already have a .ipynb sibling).
| Parser | Menu label | File type | Format |
|---|---|---|---|
parsePy |
Percent format (.py) | .py |
Jupytext percent |
parseSphinxGallery |
Sphinx Gallery (.py) | .py |
Sphinx-Gallery |
parseClassicMd |
Classic Markdown (.md) | .md |
Standard markdown — fenced code blocks become code cells |
parseMystMd |
MyST Notebook (.md) | .md |
MyST-NB {code-cell} directives |
pip uninstall ptjnbSee CONTRIBUTING.md