JupyterFormatter.jl

A simple package to automatically format Jupyter Notebook and Jupyter Lab cells using JuliaFormatter.
Author jlamberts
Popularity
3 Stars
Updated Last
2 Years Ago
Started In
May 2021

JupyterFormatter.jl

A simple package to add JuliaFormatter autoformatting support to Jupyter lab and notebooks running IJulia. Inspired by my favorite Jupyter extension, nb_black.

Usage

In your notebook,

using JupyterFormatter
enable_autoformat()

Afterwards, whenever you run a cell, it will automatically be formatted. If you want to turn off auto-formatting, run

disable_autoformat()

Jupyter Notebook and Lab Compatibility

While this package works with both legacy Jupyter Notebooks and Jupyter Lab, it does have some issues in Jupyter Notebooks. On legacy notebooks only, when a cell is formatted its output will be suppressed and it will lose its In[] and Out[]. This will only happen if the cell is not already formatted properly.

For example, running this already-formatted cell will output as normal:

Running With Formatted Cell

However, running this unformatted cell will not print properly; running this cell

Running With Formatted Cell

Results in this formatted cell with no output

Running With Formatted Cell

It is recommended that you run in Jupyter Lab if possible, since it does not have this issue.

Used By Packages

No packages found.