Skip to main content

Jupyter Notebook Table of Contents Generator

A Python library that automatically generates a table of contents for Jupyter notebooks by scanning markdown cells for headers.

Features

  • Scans Jupyter notebooks for markdown cells
  • Identifies headers (H1, H2, H3) using "#", "##", and "###" syntax
  • Generates a formatted table of contents with proper indentation
  • Supports numbered sections
  • Easy to integrate into existing notebooks
  • Automatic notebook detection
  • Hyperlinks to sections

Installation

pip install jupyter-notebook-toc

Usage

import jupyter_notebook_toc.core as toc_gen

# Generate TOC from the current notebook
toc = toc_gen.generate_toc()
print(toc)

# Or specify a notebook file
toc = toc_gen.generate_toc("path/to/your/notebook.ipynb")
print(toc)

# Or save it to a file
with open("table_of_contents.md", "w") as f:
    f.write(toc)

Command Line Usage

# Generate TOC from current notebook
jupyter-toc

# Generate TOC from specific notebook
jupyter-toc path/to/your/notebook.ipynb

# Save TOC to file
jupyter-toc -o table_of_contents.md

Example Output

# Table of Contents

1. [Introduction](#introduction)
    1.1. [Background](#background)
    1.2. [Purpose](#purpose)
2. [Methodology](#methodology)
    2.1. [Data Collection](#data-collection)
    2.2. [Analysis](#analysis)
3. [Results](#results)
    3.1. [Findings](#findings)
    3.2. [Discussion](#discussion)

Development

To set up the development environment:

  1. Clone the repository
  2. Install development dependencies:
    pip install -r requirements-dev.txt
    
  3. Run tests:
    pytest
    

License

MIT License - see LICENSE file for details

Metadata

Release files for jupyter-notebook-toc 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyter-notebook-toc 0.2.2
File Size Uploaded
jupyter_notebook_toc-0.2.2.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyter-notebook-toc 0.2.2
File Interpreter ABI Platform
jupyter_notebook_toc-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / jupyter_notebook_toc-0.2.2.tar.gz

Download URL jupyter_notebook_toc-0.2.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d7c256e397fa41ba8bab5004f94bf7bcdf3cd2fcef31073e437438a82987a8fe
BLAKE2b-256 checksum
How to use checksums
93afd5980b65e45e8d70084b15a373a9da1fcaee57535e72cd964f145843a024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release files / jupyter_notebook_toc-0.2.2-py3-none-any.whl

Download URL jupyter_notebook_toc-0.2.2-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8e9bc6796c75ee0752a876f9d801e0f7a739d3355e3bc3cd6ea8c6f03bef6f1
BLAKE2b-256 checksum
How to use checksums
d3aa6776644b829a57c816917daa8c8e48aadc51313526673339b6e99b77d124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page