Source code for nbless.nbdeck
# !/usr/bin/env python
import nbformat
[docs]def nbdeck(filename: str) -> nbformat.notebooknode.NotebookNode:
""" Set up a Jupyter notebook to be viewed as or converted into slides.
Sets `slide_type` to ``slide`` for markdown cells that start with headers.
After running ``nbdeck``, you can
- view Jupyter notebooks on nbviewer or with the RISE extension
- create an HTML slideshow with ``nbconv`` or ``jupyter nbconvert``.
:param filename: The filename of the input jupyter notebook.
"""
nb = nbformat.read(filename, as_version=4)
for n, cell in enumerate(nb.cells):
if cell.cell_type == "markdown" and cell.source.startswith("#"):
nb.cells[n].slide_type = "slide"
return nb