Skip to main content

A tool that exports a Jupyter Notebook to HTML format using nbconvert’s HTMLExporter, enabling web-based presentation of notebooks.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_jupyterexporthtml


Swarmauri Tool Jupyter Export HTML

Converts a Jupyter notebook (passed in as JSON) to HTML using nbconvert’s HTMLExporter with optional custom templates, CSS, and JavaScript.

Features

  • Accepts notebook data as a JSON string (e.g., from json.dumps(nbformat.read(...))).
  • Supports optional template, inline CSS, and inline JS injection.
  • Returns a dict containing exported_html or error when conversion fails.

Prerequisites

  • Python 3.10 or newer.
  • nbconvert, nbformat, and Swarmauri base/core packages (installed automatically).

Installation

# pip
pip install swarmauri_tool_jupyterexporthtml

# poetry
poetry add swarmauri_tool_jupyterexporthtml

# uv (pyproject-based projects)
uv add swarmauri_tool_jupyterexporthtml

Quickstart

import json
import nbformat
from swarmauri_tool_jupyterexporthtml import JupyterExportHTMLTool

notebook = nbformat.read("notebooks/example.ipynb", as_version=4)
notebook_json = json.dumps(notebook)

exporter = JupyterExportHTMLTool()
response = exporter(
    notebook_json=notebook_json,
    template_file=None,
    extra_css="body { font-family: Arial; }",
    extra_js="console.log('Export complete');",
)

if "exported_html" in response:
    Path("notebooks/example.html").write_text(response["exported_html"], encoding="utf-8")
else:
    print("Error:", response["error"])

Tips

  • nbconvert templates let you customize the layout; pass a .tpl file to template_file.
  • Keep extra_css/extra_js lightweight to avoid bloating the HTML output.
  • Combine with notebook execution tools (execute → export → publish) for end-to-end pipelines.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

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

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

File details

Details for the file swarmauri_tool_jupyterexporthtml-0.9.0.dev4.tar.gz.

File metadata

  • Download URL: swarmauri_tool_jupyterexporthtml-0.9.0.dev4.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_jupyterexporthtml-0.9.0.dev4.tar.gz
Algorithm Hash digest
SHA256 0f1f8fbac018f862c593eaa5d6b6bf6a27ef6ad6325b174bb517672aafe11f7d
MD5 d7324b85f44ea9735581b1cb9c8428fb
BLAKE2b-256 16fb82c3d3858206a7c822d0eaee85ab8879e410e6171ab851f7b007aaccf66f

See more details on using hashes here.

File details

Details for the file swarmauri_tool_jupyterexporthtml-0.9.0.dev4-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_jupyterexporthtml-0.9.0.dev4-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_jupyterexporthtml-0.9.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 bcd490603326470b698f051af54a31a5284b1fa6ce5b32e28fe1e73fac908267
MD5 4c18eb540af6471083ee6acc04adea4b
BLAKE2b-256 40e235b46448033f1c0447431e59661e0439fe8a8f5c66d48e768ece841bfeb3

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