Skip to main content

Write in Jupyter Notebooks. Publish anywhere.

Project description

nb2wb

Write in notebooks. Publish anywhere.

nb2wb converts Jupyter Notebooks and other notebook-style content into publishable HTML for Substack, Medium, and X Articles.

Supported inputs:

  • Jupyter notebooks (.ipynb)
  • Quarto documents (.qmd)
  • Markdown documents (.md)
  • in-memory Jupyter notebook payloads (dict / NotebookNode)

Documentation

  • Detailed docs (Read the Docs): https://nb2wb.readthedocs.io/
  • Docs source in this repo: docs/index.md

Brief Feature Tour

  1. Load notebook content from file or in-memory payload.
  2. Optionally execute code cells (--execute / execute=True).
  3. Render markdown, math, code, and outputs into platform-safe HTML fragments.
  4. Convert display math, code, and (optionally) tables to images for high-fidelity publishing.
  5. Sanitize rich HTML/SVG output and enforce server-side safety limits.
  6. Wrap output for your target platform (substack, medium, x).

Installation

pip install nb2wb

Development install:

git clone https://github.com/the-palindrome/nb2wb.git
cd nb2wb
pip install -e ".[dev]"

Quick Start (CLI)

nb2wb notebook.ipynb
nb2wb notebook.ipynb -t medium
nb2wb notebook.ipynb -t x
nb2wb notebook.ipynb -o article.html
nb2wb notebook.ipynb --open
nb2wb notebook.ipynb --serve
nb2wb notebook.ipynb --raw -o article_raw.html
nb2wb report.qmd --execute

Quick Start (Python API)

import nb2wb

# Path input via loader helper
payload = nb2wb.load_input_payload("notebook.ipynb")
html = nb2wb.convert(
    payload,
    target="substack",
    config={"latex": {"try_usetex": True}},
)

# In-memory payload input (JSON / JSONB parsed notebook)
html = nb2wb.convert(
    notebook_payload,
    target="substack",
    execute=False,
)

# Raw-mode output (no <head>, toolbar, or JavaScript)
html = nb2wb.convert(
    notebook_payload,
    target="medium",
    raw_mode=True,
)

nb2wb.convert() is content-only; use load_input_payload() (or typed loaders) for filesystem inputs.

Security at a Glance

nb2wb uses a mandatory server-safe conversion pipeline:

  • strict HTML/SVG sanitization
  • CSS URL sanitization
  • SSRF-safe image fetching
  • path traversal protection for local files
  • notebook size/resource safety limits
  • fail-closed behavior for unsafe/unresolvable image sources

Important: enabling execution runs notebook code. Treat execute=True workloads as untrusted code and isolate them appropriately.

Configuration

Use YAML file in CLI:

nb2wb notebook.ipynb -c config.yaml

Or pass dict/object/path in API:

html = nb2wb.convert(notebook_payload, config={"safety": {"max_cells": 1500}})

Read More

Development

Run tests:

pytest

Build docs locally:

pip install -e ".[docs]"
sphinx-build -b html docs docs/_build/html

License

MIT

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

nb2wb-0.2.1.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

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

nb2wb-0.2.1-py3-none-any.whl (57.3 kB view details)

Uploaded Python 3

File details

Details for the file nb2wb-0.2.1.tar.gz.

File metadata

  • Download URL: nb2wb-0.2.1.tar.gz
  • Upload date:
  • Size: 49.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nb2wb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4f4fea39f576b494cd364ae2beef23839dd1bbee4d0072cce32df14fdb675318
MD5 ada566880145a4eb6dfde898492a7495
BLAKE2b-256 1ecc0c5c3618f994e10392374a9731685305aa69cb66e7884a166296fd3c8527

See more details on using hashes here.

Provenance

The following attestation bundles were made for nb2wb-0.2.1.tar.gz:

Publisher: publish.yml on the-palindrome/nb2wb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nb2wb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: nb2wb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 57.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nb2wb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75b3549eb6b7dc55c2d1d791e7ace129638c7aeda3fd04f8e99d3d8f3474ec70
MD5 ac738b616eb9a524edc15053dce19c18
BLAKE2b-256 682d5dff4251b817ae07bac8bb1fba628e0b726a48166c0181a3aa75f5511f3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nb2wb-0.2.1-py3-none-any.whl:

Publisher: publish.yml on the-palindrome/nb2wb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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