Skip to main content

A tool to generate table of contents for Jupyter notebooks

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_notebook_toc-0.1.8.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_notebook_toc-0.1.8-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_notebook_toc-0.1.8.tar.gz.

File metadata

  • Download URL: jupyter_notebook_toc-0.1.8.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for jupyter_notebook_toc-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8e519b8b4be77fe55af4b9ee2afe9b0d74e51e9a7c306b891978bbf73aa7cdb3
MD5 449231cedd4cdff79b1f2f51614677ca
BLAKE2b-256 54e1a060074b5120e0c0c8dff83544c3c3d0f3383d1e59bb82463d829a7ebdf3

See more details on using hashes here.

File details

Details for the file jupyter_notebook_toc-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_notebook_toc-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e02c2967fbb635adff32683e409514d94a73f75aec89eeb45e02a54b7b9520
MD5 be7ee6987884e13c7773ad4b37a79f21
BLAKE2b-256 ab05ca3bd3d4953d58f08902483a16be9015dd18b2ceeb8650aaefd8817f0994

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page