jupyterlab-mmd-to-png-extension


Namejupyterlab-mmd-to-png-extension JSON
Version 1.0.6 PyPI version JSON
download
home_pageNone
SummaryJupyterlab extension for markdown files with Mermaid diagrams to allow copying of mermaid diagrams as PNG images
upload_time2025-11-02 22:41:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseBSD 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.
keywords jupyter jupyterlab jupyterlab-extension
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JupyterLab Mermaid to PNG Extension

![GitHub Actions](https://github.com/stellarshenson/jupyterlab_mmd_to_png_extension/actions/workflows/build.yml/badge.svg)
[![npm version](https://badge.fury.io/js/jupyterlab_mmd_to_png_extension.svg)](https://www.npmjs.com/package/jupyterlab_mmd_to_png_extension)
[![PyPI version](https://badge.fury.io/py/jupyterlab-mmd-to-png-extension.svg)](https://pypi.org/project/jupyterlab-mmd-to-png-extension/)
[![Total PyPI downloads](https://static.pepy.tech/badge/jupyterlab-mmd-to-png-extension)](https://pepy.tech/project/jupyterlab-mmd-to-png-extension)
![JL4 Ready](https://img.shields.io/badge/Jupyterlab%204-ready-blue)

Export Mermaid diagrams from JupyterLab markdown files as high-quality PNG images. Right-click any rendered diagram in the markdown viewer to copy or save it as a PNG file with configurable resolution settings.

![Extension Screenshot](.resources/screenshot.png)

## Features

**Core capabilities:**
- Copy diagrams directly to clipboard as PNG images
- Save diagrams as PNG files with deterministic content-based filenames
- Configurable DPI resolution from 72 to 1200 (default 300)
- Transparent backgrounds for seamless integration into documents
- Zero configuration required - works immediately after installation

**Technical implementation:**
- Pure client-side rendering using browser canvas API
- No external services or command-line tools required
- Calibrated DPI conversion matching Adobe converter output (±0.07% accuracy)
- Context menu integration in markdown viewer only

## Requirements

- JupyterLab >= 4.0.0

## Installation

Install from PyPI using pip:

```bash
pip install jupyterlab_mmd_to_png_extension
```

After installation, restart JupyterLab to activate the extension.

## Usage

Open any markdown file containing Mermaid diagrams in JupyterLab. The extension adds two options to the context menu when you right-click on a rendered diagram in the markdown viewer:

**Copy as PNG** - Copies the diagram to your clipboard as a PNG image. Paste directly into documents, presentations, or image editors.

**Save as PNG** - Downloads the diagram as a PNG file. Filenames follow the pattern `mermaid-<document-name>-<content-hash>.png` where the hash is generated from the diagram content, ensuring consistent filenames for identical diagrams.

### DPI Configuration

Adjust export resolution through JupyterLab's settings interface. Navigate to Settings -> Advanced Settings Editor -> Mermaid to PNG Extension. The default DPI is 300 (standard print quality), with a range from 72 (screen resolution) to 1200 (professional print quality).

## Example

Create a markdown file with a Mermaid diagram:

```markdown
```mermaid
graph TD
    A[Start] -> B[Process]
    B -> C[End]
```
```

Render the markdown file in JupyterLab's viewer. Right-click the diagram and select either "Copy as PNG" or "Save as PNG". The exported image will use your configured DPI setting and include a transparent background.

## Uninstall

Remove the extension using pip:

```bash
pip uninstall jupyterlab_mmd_to_png_extension
```

## Troubleshooting

If the extension is not appearing in the context menu, verify both the server and frontend extensions are properly installed and enabled.

Check server extension status:
```bash
jupyter server extension list
```

Check frontend extension status:
```bash
jupyter labextension list
```

Both should show `jupyterlab_mmd_to_png_extension` as enabled. If either is missing or disabled, reinstall the extension and restart JupyterLab.

## Contributing

### Development Setup

Install the extension in development mode. This requires NodeJS for building the TypeScript source code. The `jlpm` command is JupyterLab's pinned version of yarn.

```bash
# Install package in development mode
pip install -e ".[test]"

# Link development version with JupyterLab
jupyter labextension develop . --overwrite

# Enable server extension manually (required in development mode)
jupyter server extension enable jupyterlab_mmd_to_png_extension

# Build the extension
jlpm build
```

### Development Workflow

Run the watch command in one terminal to automatically rebuild on file changes:

```bash
jlpm watch
```

Run JupyterLab in a separate terminal:

```bash
jupyter lab
```

The extension rebuilds automatically when you save changes. Refresh your browser to load the updated extension (allow a few seconds for rebuild completion).

### Development Uninstall

Disable the server extension and remove the package:

```bash
jupyter server extension disable jupyterlab_mmd_to_png_extension
pip uninstall jupyterlab_mmd_to_png_extension
```

Remove the symlink created by `jupyter labextension develop`. Use `jupyter labextension list` to locate the `labextensions` folder, then delete the `jupyterlab_mmd_to_png_extension` symlink within that folder.

### Testing

**Python tests** use Pytest:
```bash
pip install -e ".[test]"
pytest -vv -r ap --cov jupyterlab_mmd_to_png_extension
```

**JavaScript tests** use Jest:
```bash
jlpm
jlpm test
```

**Integration tests** use Playwright with the Galata framework for JupyterLab UI testing. See [ui-tests/README.md](./ui-tests/README.md) for details.

### Release Process

See [RELEASE.md](RELEASE.md) for packaging and publishing instructions.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jupyterlab-mmd-to-png-extension",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "jupyter, jupyterlab, jupyterlab-extension",
    "author": null,
    "author_email": "Stellars Henson <konrad.jelen@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/df/4e/27369448e3cff80069f4523006dec05dbd533c5a396674454ac1418dfc2d/jupyterlab_mmd_to_png_extension-1.0.6.tar.gz",
    "platform": null,
    "description": "# JupyterLab Mermaid to PNG Extension\n\n![GitHub Actions](https://github.com/stellarshenson/jupyterlab_mmd_to_png_extension/actions/workflows/build.yml/badge.svg)\n[![npm version](https://badge.fury.io/js/jupyterlab_mmd_to_png_extension.svg)](https://www.npmjs.com/package/jupyterlab_mmd_to_png_extension)\n[![PyPI version](https://badge.fury.io/py/jupyterlab-mmd-to-png-extension.svg)](https://pypi.org/project/jupyterlab-mmd-to-png-extension/)\n[![Total PyPI downloads](https://static.pepy.tech/badge/jupyterlab-mmd-to-png-extension)](https://pepy.tech/project/jupyterlab-mmd-to-png-extension)\n![JL4 Ready](https://img.shields.io/badge/Jupyterlab%204-ready-blue)\n\nExport Mermaid diagrams from JupyterLab markdown files as high-quality PNG images. Right-click any rendered diagram in the markdown viewer to copy or save it as a PNG file with configurable resolution settings.\n\n![Extension Screenshot](.resources/screenshot.png)\n\n## Features\n\n**Core capabilities:**\n- Copy diagrams directly to clipboard as PNG images\n- Save diagrams as PNG files with deterministic content-based filenames\n- Configurable DPI resolution from 72 to 1200 (default 300)\n- Transparent backgrounds for seamless integration into documents\n- Zero configuration required - works immediately after installation\n\n**Technical implementation:**\n- Pure client-side rendering using browser canvas API\n- No external services or command-line tools required\n- Calibrated DPI conversion matching Adobe converter output (\u00b10.07% accuracy)\n- Context menu integration in markdown viewer only\n\n## Requirements\n\n- JupyterLab >= 4.0.0\n\n## Installation\n\nInstall from PyPI using pip:\n\n```bash\npip install jupyterlab_mmd_to_png_extension\n```\n\nAfter installation, restart JupyterLab to activate the extension.\n\n## Usage\n\nOpen any markdown file containing Mermaid diagrams in JupyterLab. The extension adds two options to the context menu when you right-click on a rendered diagram in the markdown viewer:\n\n**Copy as PNG** - Copies the diagram to your clipboard as a PNG image. Paste directly into documents, presentations, or image editors.\n\n**Save as PNG** - Downloads the diagram as a PNG file. Filenames follow the pattern `mermaid-<document-name>-<content-hash>.png` where the hash is generated from the diagram content, ensuring consistent filenames for identical diagrams.\n\n### DPI Configuration\n\nAdjust export resolution through JupyterLab's settings interface. Navigate to Settings -> Advanced Settings Editor -> Mermaid to PNG Extension. The default DPI is 300 (standard print quality), with a range from 72 (screen resolution) to 1200 (professional print quality).\n\n## Example\n\nCreate a markdown file with a Mermaid diagram:\n\n```markdown\n```mermaid\ngraph TD\n    A[Start] -> B[Process]\n    B -> C[End]\n```\n```\n\nRender the markdown file in JupyterLab's viewer. Right-click the diagram and select either \"Copy as PNG\" or \"Save as PNG\". The exported image will use your configured DPI setting and include a transparent background.\n\n## Uninstall\n\nRemove the extension using pip:\n\n```bash\npip uninstall jupyterlab_mmd_to_png_extension\n```\n\n## Troubleshooting\n\nIf the extension is not appearing in the context menu, verify both the server and frontend extensions are properly installed and enabled.\n\nCheck server extension status:\n```bash\njupyter server extension list\n```\n\nCheck frontend extension status:\n```bash\njupyter labextension list\n```\n\nBoth should show `jupyterlab_mmd_to_png_extension` as enabled. If either is missing or disabled, reinstall the extension and restart JupyterLab.\n\n## Contributing\n\n### Development Setup\n\nInstall the extension in development mode. This requires NodeJS for building the TypeScript source code. The `jlpm` command is JupyterLab's pinned version of yarn.\n\n```bash\n# Install package in development mode\npip install -e \".[test]\"\n\n# Link development version with JupyterLab\njupyter labextension develop . --overwrite\n\n# Enable server extension manually (required in development mode)\njupyter server extension enable jupyterlab_mmd_to_png_extension\n\n# Build the extension\njlpm build\n```\n\n### Development Workflow\n\nRun the watch command in one terminal to automatically rebuild on file changes:\n\n```bash\njlpm watch\n```\n\nRun JupyterLab in a separate terminal:\n\n```bash\njupyter lab\n```\n\nThe extension rebuilds automatically when you save changes. Refresh your browser to load the updated extension (allow a few seconds for rebuild completion).\n\n### Development Uninstall\n\nDisable the server extension and remove the package:\n\n```bash\njupyter server extension disable jupyterlab_mmd_to_png_extension\npip uninstall jupyterlab_mmd_to_png_extension\n```\n\nRemove the symlink created by `jupyter labextension develop`. Use `jupyter labextension list` to locate the `labextensions` folder, then delete the `jupyterlab_mmd_to_png_extension` symlink within that folder.\n\n### Testing\n\n**Python tests** use Pytest:\n```bash\npip install -e \".[test]\"\npytest -vv -r ap --cov jupyterlab_mmd_to_png_extension\n```\n\n**JavaScript tests** use Jest:\n```bash\njlpm\njlpm test\n```\n\n**Integration tests** use Playwright with the Galata framework for JupyterLab UI testing. See [ui-tests/README.md](./ui-tests/README.md) for details.\n\n### Release Process\n\nSee [RELEASE.md](RELEASE.md) for packaging and publishing instructions.\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License\n        \n        Copyright (c) 2025, Stellars Henson\n        All rights reserved.\n        \n        Redistribution and use in source and binary forms, with or without\n        modification, are permitted provided that the following conditions are met:\n        \n        1. Redistributions of source code must retain the above copyright notice, this\n           list of conditions and the following disclaimer.\n        \n        2. Redistributions in binary form must reproduce the above copyright notice,\n           this list of conditions and the following disclaimer in the documentation\n           and/or other materials provided with the distribution.\n        \n        3. Neither the name of the copyright holder nor the names of its\n           contributors may be used to endorse or promote products derived from\n           this software without specific prior written permission.\n        \n        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
    "summary": "Jupyterlab extension for markdown files with Mermaid diagrams to allow copying of mermaid diagrams as PNG images",
    "version": "1.0.6",
    "project_urls": {
        "Bug Tracker": "https://github.com/stellarshenson/jupyterlab_mmd_to_png_extension/issues",
        "Homepage": "https://github.com/stellarshenson/jupyterlab_mmd_to_png_extension",
        "Repository": "https://github.com/stellarshenson/jupyterlab_mmd_to_png_extension.git"
    },
    "split_keywords": [
        "jupyter",
        " jupyterlab",
        " jupyterlab-extension"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "60bb68529c7dfcc9abb52e30c8add17c515be9ea10d0c26018fa7e4326d2e689",
                "md5": "5ed2bc4207f44e885b87755c6f8675cb",
                "sha256": "a29e3bdf3015268fa0478c23607fcb4e65baa2322dcd38b0c6595b79ba5aed79"
            },
            "downloads": -1,
            "filename": "jupyterlab_mmd_to_png_extension-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5ed2bc4207f44e885b87755c6f8675cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 24059,
            "upload_time": "2025-11-02T22:41:00",
            "upload_time_iso_8601": "2025-11-02T22:41:00.557552Z",
            "url": "https://files.pythonhosted.org/packages/60/bb/68529c7dfcc9abb52e30c8add17c515be9ea10d0c26018fa7e4326d2e689/jupyterlab_mmd_to_png_extension-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "df4e27369448e3cff80069f4523006dec05dbd533c5a396674454ac1418dfc2d",
                "md5": "4fe71c0abd76d3687cdc77f7e8103e69",
                "sha256": "3179852430a5c23e3bdf979e2e28f8a4881aafa3f3648c2f93355622669234b4"
            },
            "downloads": -1,
            "filename": "jupyterlab_mmd_to_png_extension-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "4fe71c0abd76d3687cdc77f7e8103e69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 443734,
            "upload_time": "2025-11-02T22:41:01",
            "upload_time_iso_8601": "2025-11-02T22:41:01.839423Z",
            "url": "https://files.pythonhosted.org/packages/df/4e/27369448e3cff80069f4523006dec05dbd533c5a396674454ac1418dfc2d/jupyterlab_mmd_to_png_extension-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-02 22:41:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "stellarshenson",
    "github_project": "jupyterlab_mmd_to_png_extension",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "jupyterlab-mmd-to-png-extension"
}
        
Elapsed time: 1.47148s