Skip to content

📌 A commmand-line interface to add or update TOC to Jupyter Notebooks

License

Notifications You must be signed in to change notification settings

axelbellec/Jupytoc

Repository files navigation

jupytoc_logo


Jupytoc generates table of contents for jupyter notebook files. Links are compatible with anchors generated by GitHub.



$ jupytoc

📌 A commmand-line interface to add/update/delete TOC to Jupyter Notebooks

Usage

toc_build

Simplest usage

$ jupytoc <jupyter_notebook>

To add toc for all files in a directory, just launch:

$ jupytoc .

CLI args/otps

$ jupytoc --help
Usage: jupytoc [OPTIONS] [NOTEBOOKS]...

Options:
  -R, --recursive         build TOC for all subdirectories recursively
  -l, --maxlevel INTEGER  limit TOC entries to headings only up to the
                          specified level
  -t, --title TEXT        custom TOC title
  -s, --stdout            print to stdout
  -d, --delete            remove TOC from notebook file
  --help                  Show this message and exit.

Adding (or update) TOC to all notebooks in a directory and sub directories

$ jupytoc -R

Custom TOC title

Use --title option to specify a custom TOC title (Markdown formatted). e.g. :

$ jupytoc --title '**Contents**'

Maximum heading level

Use --maxlevel option to limit TOC entries to a certain level. By default, Jupyter Notebook headings are limited to 6 levels.

$ jupytoc --maxlevel 2

Print generated TOC to stdout

Use --stdout flag to print to stdout.

$ jupytoc --stdout

Deleting TOC

Use --delete option to delete a TOC.

$ jupytoc --delete <jupyter_notebook>

Installation

GitHub for the latest development version

$ pip install git+https://github.com/axelbellec/jupytoc

Jupytoc has the following dependencies:

  • click: a command line library for Python
  • emoji: emoji terminal output for Python

Features

Done

  • generate TOC a top of file
  • add/update an existing TOC in Markdown file
  • add/update TOC for all files in the current directory
  • handle multiple files input
  • limit TOC entries
  • add/udpate TOC to all files in a directory/sub directories
  • enable custom TOC title editing
  • print TOC to stdout
  • delete TOC option

Still in development

  • Test suite

FAQ

1. Why do my link anchors generated with jupytoc not work when the notebook is read on Github?

GitHub rending concerning .ipynb notebooks do not let us to navigate through links.

About

📌 A commmand-line interface to add or update TOC to Jupyter Notebooks

Resources

License

Stars

Watchers

Forks

Packages

No packages published