Skip to main content

Jupyterlab extension to automatically insert content into markdown - such as TOC, bibliography, list of figures etc.

Project description

jupyterlab_markdown_insert_content_extension

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO Donate PayPal

JupyterLab extension for inserting reusable content blocks into markdown files and notebook cells, starting with automatic table of contents generation.

Right-click in markdown editor or notebook cell to access the context menu:

Generated table of contents with hierarchical structure and working anchor links:

Configure TOC caption and maximum heading level through JupyterLab settings:

Features

  • Context menu integration - right-click in markdown editors or notebook cells to access all tools via "Markdown Tools" submenu
  • Table of contents generation - automatically extracts headings and creates hierarchical TOC with working anchor links
  • TOC update support - regenerates existing TOC in place using markers (<!-- TOC:BEGIN --> and <!-- TOC:END -->)
  • Per-TOC depth configuration - each TOC stores its depth in the marker (<!-- TOC:BEGIN DEPTH=3 -->) and preserves it across updates
  • Heading exclusion - mark headings with <!-- TOC:IGNORE --> to exclude from TOC while preserving numbering
  • Hierarchical heading numbering - add, remove, or update numbering on headings (1., 1.1., 1.1.2., etc.)
  • Configurable settings - customize TOC caption, maximum heading depth, numbering depth, and trailing dot style
  • Code block filtering - excludes headings within fenced code blocks from TOC and numbering
  • JupyterLab-compatible anchors - generates anchor IDs matching JupyterLab's format for reliable navigation
  • Dual mode support - works in both markdown file editors and notebook markdown cells
  • Cursor-aware insertion - inserts content at current cursor position
  • Automatic TOC updates - TOC is updated automatically when heading numbering changes

Requirements

  • JupyterLab >= 4.0.0

Install

pip install jupyterlab_markdown_insert_content_extension

Usage

Table of Contents

  1. Open a markdown file or create a markdown cell in a notebook
  2. Position cursor where you want the TOC inserted
  3. Right-click and select Markdown Tools > Insert Table of Contents
  4. TOC is generated with markers for future updates

To update an existing TOC:

  • Right-click and select Markdown Tools > Update Table of Contents
  • The TOC between markers will be regenerated

Heading Numbering

Add hierarchical numbering to your headings:

  1. Right-click and select Markdown Tools > Add Heading Numbering
  2. Headings become numbered: # Introduction -> # 1. Introduction

Other numbering commands:

  • Remove Heading Numbering - strips all numbering from headings
  • Update Heading Numbering - recalculates numbering and updates TOC

Configure Settings

Access settings through Settings -> Settings Editor -> Markdown Insert Content:

  • TOC Caption - markdown content inserted before TOC list (default: **Table of Contents**)
  • Maximum TOC Heading Level - deepest heading level to include in TOC (1-6, default: 3)
  • Maximum Numbering Level - deepest heading level to number (1-6, default: 3)
  • Trailing Dot in Numbering - add trailing dot after numbers (default: enabled, e.g., 1.2. vs 1.2)

Settings apply immediately without restart.

Uninstall

pip uninstall jupyterlab_markdown_insert_content_extension

Development

Development install

# Clone repository
git clone https://github.com/stellarshenson/jupyterlab_markdown_insert_content_extension.git
cd jupyterlab_markdown_insert_content_extension

# Set up virtual environment
python -m venv .venv
source .venv/bin/activate
pip install --editable "."

# Link extension with JupyterLab
jupyter labextension develop . --overwrite

# Build extension
jlpm install
jlpm build

Development workflow

# Watch mode - automatically rebuilds on changes
jlpm watch

# In another terminal, run JupyterLab
jupyter lab

Refresh JupyterLab after changes to load updated extension.

Development uninstall

pip uninstall jupyterlab_markdown_insert_content_extension
jupyter labextension list  # Find labextensions folder
# Remove symlink from labextensions folder

Testing

Frontend tests:

jlpm test

Integration tests: See ui-tests/README.md for Playwright integration tests.

Packaging

See RELEASE.md for release process.

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

Built Distribution

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

File details

Details for the file jupyterlab_markdown_insert_content_extension-1.1.15.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_markdown_insert_content_extension-1.1.15.tar.gz
Algorithm Hash digest
SHA256 38d6a6fe64a3e4d4de7c0d045cc02bc14eaca156cc7567814f481893fde830a8
MD5 950328ab7b37ba07968d8fe90d534c31
BLAKE2b-256 ea9499bccb1e024fe557a93c4f5751f16d8d0eef99937ca2d66c2331303ac16d

See more details on using hashes here.

File details

Details for the file jupyterlab_markdown_insert_content_extension-1.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_markdown_insert_content_extension-1.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 6ae328d0cf85cd62b7d3dbec0b2dfba4f35fddaf04afd423d491f54889d50c7e
MD5 7e063f589e690e6fe75ce20252be12db
BLAKE2b-256 4324c18985f64d47adc54b90316da2f2a3dc009c0155fa7b495c04e892c7c69b

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