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:
- Clone the repository
- Install development dependencies:
pip install -r requirements-dev.txt
- Run tests:
pytest
License
MIT License - see LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_notebook_toc-0.2.0.tar.gz.
File metadata
- Download URL: jupyter_notebook_toc-0.2.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6823c393779f110dfb7ab307229656153e242555d96065be48cbe7c8b3fb2519
|
|
| MD5 |
b972a9e00cd3224f071cd11646414013
|
|
| BLAKE2b-256 |
01cb8d46565186ea9e34380f9f9183d54cf2986b5adbc441b58db660783ca3f8
|
File details
Details for the file jupyter_notebook_toc-0.2.0-py3-none-any.whl.
File metadata
- Download URL: jupyter_notebook_toc-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75ab7336818f8870cc2dd42fab7f752d2ef69e7919f0d638a6705d52e0e7637d
|
|
| MD5 |
ee40711dcb0878042163157170bcae1a
|
|
| BLAKE2b-256 |
0e09fe65209536c6da558f90db26d509f2f89730942056b31f550eace0a814cb
|