Metadata-Version: 2.4
Name: jupyterlab_markdown_insert_content_extension
Version: 1.0.40
Summary: Jupyterlab extension to automatically insert content into markdown - such as TOC, bibliography, list of figures etc.
Project-URL: Homepage, https://github.com/stellarshenson/jupyterlab_markdown_insert_content_extension
Project-URL: Bug Tracker, https://github.com/stellarshenson/jupyterlab_markdown_insert_content_extension/issues
Project-URL: Repository, https://github.com/stellarshenson/jupyterlab_markdown_insert_content_extension.git
Author-email: Stellars Henson <konrad.jelen@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Stellars Henson
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: jupyter,jupyterlab,jupyterlab-extension
Classifier: Framework :: Jupyter
Classifier: Framework :: Jupyter :: JupyterLab
Classifier: Framework :: Jupyter :: JupyterLab :: 4
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# jupyterlab_markdown_insert_content_extension

[![GitHub Actions](https://github.com/stellarshenson/jupyterlab_markdown_insert_content_extension/actions/workflows/build.yml/badge.svg)](https://github.com/stellarshenson/jupyterlab_markdown_insert_content_extension/actions/workflows/build.yml)
[![npm version](https://img.shields.io/npm/v/jupyterlab_markdown_insert_content_extension.svg)](https://www.npmjs.com/package/jupyterlab_markdown_insert_content_extension)
[![PyPI version](https://img.shields.io/pypi/v/jupyterlab_markdown_insert_content_extension.svg)](https://pypi.org/project/jupyterlab_markdown_insert_content_extension/)
[![Total PyPI downloads](https://static.pepy.tech/badge/jupyterlab_markdown_insert_content_extension)](https://pepy.tech/project/jupyterlab_markdown_insert_content_extension)
[![JupyterLab 4](https://img.shields.io/badge/JupyterLab-4-orange.svg)](https://jupyterlab.readthedocs.io/en/stable/)

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

## Features

- **Context menu integration** - right-click in markdown editors or notebook cells to insert content
- **Table of contents generation** - automatically extracts headings and creates hierarchical TOC with working anchor links
- **Configurable settings** - customize TOC caption and maximum heading depth through JupyterLab settings
- **Code block filtering** - excludes headings within fenced code blocks from TOC
- **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

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

![](.resources/screenshot-menu.png)

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

![](.resources/screenshot-toc.png)

Configure TOC caption and maximum heading level through JupyterLab settings:

![](.resources/screenshot-settings.png)

## Requirements

- JupyterLab >= 4.0.0

## Install

```bash
pip install jupyterlab_markdown_insert_content_extension
```

## Usage

### Insert 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 "Insert Table of Contents"
4. TOC is generated with links to all headings in the document

### Configure Settings

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

- **TOC Caption** - markdown content inserted before TOC list (default: `## Table of Contents`)
- **Maximum Heading Level** - deepest heading level to include (1-6, default: 3)

Settings apply immediately without restart.

## Uninstall

```bash
pip uninstall jupyterlab_markdown_insert_content_extension
```

## Development

### Development install

```bash
# 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

```bash
# 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

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

### Testing

**Frontend tests**:

```bash
jlpm test
```

**Integration tests**:
See [ui-tests/README.md](./ui-tests/README.md) for Playwright integration tests.

### Packaging

See [RELEASE.md](RELEASE.md) for release process.
