All of the following preprocessors are run over the notebooks.


This runs the standard tag-remover and removes any cells with the tag remove_cell.

Adds in links from one page to the next. The order is based on the naming of the main pages’ numbers. i.e. 00 Intro.ipynb` will have a next link to ``01 Foo.ipynb.

class nbpretty.preprocessors.HighlightExercises(**kwargs: Any)#

Any cells with the tag exercise will have the exercise css class attached to them. By default this highlights the output cell in yellow.

class nbpretty.preprocessors.SetTitle(**kwargs: Any)#

Based on the course_title in config.yaml this sets the title at the top of each page and in the HTML header.

class nbpretty.preprocessors.HideWriteFileMagic(**kwargs: Any)#

This looks for cells which start with %%writefile, %run, %cd or ! and hides that from the output. For %%writefile it removes that line, sets the output prompt to the name of the file and hides the output “Overwriting”. For %run it turns it into python and sets the prompt to $ to indicate running in the terminal. For %cd it changes it into cd and for ! it just shows the run command.

class nbpretty.preprocessors.FixLinkExtensions(**kwargs: Any)#

Replaces all .ipynb with .html so that links continue to work.

class nbpretty.preprocessors.CustomBlocks(**kwargs: Any)#

Based on the custom_blocks list in config.yaml it sets all cells with a tag matching a custom block name to be collapsible by clicking on the image that goes in the prompt.

class nbpretty.preprocessors.InsertTOC(**kwargs: Any)#

Replaces all cells with the tag toc with the table on contents, based on the file naming.

class nbpretty.preprocessors.UninlineCss(**kwargs: Any)#

Moves the inlined CSS generated by nbconvert into a separate file which is referenced by all notebooks.

class nbpretty.preprocessors.AddExtraCss(**kwargs: Any)#

If the extra CSS file is give, add it to the metadata.