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 with a neutral default mode plus platform profiles for Substack, Medium, X Articles, LinkedIn, Dev.to, Hashnode, Ghost, and WordPress.
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
- Load notebook content from file or in-memory payload.
- Optionally execute code cells (
--execute/execute=True). - Render markdown, math, code, and outputs into platform-safe HTML fragments.
- Convert display math, code, and (optionally) tables to images for high-fidelity publishing.
- Sanitize rich HTML/SVG output and enforce server-side safety limits.
- Wrap output for your target platform (
default,substack,medium,x,linkedin,devto,hashnode,ghost,wordpress).
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 -t linkedin
nb2wb notebook.ipynb -t devto
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
nb2wb report.ipynb --warnings
nb2wb report.ipynb -t ghost --image-strategy embed --article-width 900
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,
)
# Restore stderr warning/log output rendering when needed
html = nb2wb.convert(
notebook_payload,
target="default",
warnings_mode=True,
)
# Override target features at call-time
html = nb2wb.convert(
notebook_payload,
target="devto",
target_options={
"image_strategy": "copyable",
"copy_script_mode": "copyable",
"article_width_px": 780,
},
)
nb2wb.convert() is content-only; use load_input_payload() (or typed loaders) for filesystem inputs.
Loader helpers return a validated NotebookNode for .ipynb inputs and
{"format": ..., "content": ...} mappings for .md and .qmd inputs.
Passing a Path object to nb2wb.convert() raises TypeError. Passing a
plain string such as "notebook.ipynb" is treated as document text, not as a
filesystem path.
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
- Feature Tour
- Getting Started
- CLI Reference
- Python API
- Input Formats
- Configuration
- Platforms
- Security Model
- FastAPI/API Integration
- Troubleshooting
- For Maintainers
Development
Run tests:
pytest
Detailed suite guide: tests/README.md
Build docs locally:
pip install -e ".[docs]"
sphinx-build -b html docs docs/_build/html
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nb2wb-0.2.4.tar.gz.
File metadata
- Download URL: nb2wb-0.2.4.tar.gz
- Upload date:
- Size: 59.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fede453e4c0f0bc881c6997c0ff78c63d819730c6cb6ae37314a12ee4ba75202
|
|
| MD5 |
13153732fca92cdd72f4554f15bd2962
|
|
| BLAKE2b-256 |
bac4c72dea7790d06be921b464af130316bda22fe2cac921c44f1578f6c17ca0
|
Provenance
The following attestation bundles were made for nb2wb-0.2.4.tar.gz:
Publisher:
publish.yml on the-palindrome/nb2wb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nb2wb-0.2.4.tar.gz -
Subject digest:
fede453e4c0f0bc881c6997c0ff78c63d819730c6cb6ae37314a12ee4ba75202 - Sigstore transparency entry: 1096863677
- Sigstore integration time:
-
Permalink:
the-palindrome/nb2wb@6e5bd42b2c4029f1d1cd0c614bfc18c28ee94b45 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/the-palindrome
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6e5bd42b2c4029f1d1cd0c614bfc18c28ee94b45 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nb2wb-0.2.4-py3-none-any.whl.
File metadata
- Download URL: nb2wb-0.2.4-py3-none-any.whl
- Upload date:
- Size: 66.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
407161cbf03f952d65764b6c65ee76d60c6d4a654ee0b2da25cf0e59cb43557b
|
|
| MD5 |
eeed087731113980fdd4ec93ed39640d
|
|
| BLAKE2b-256 |
608918bc1f5dcbe965f37822f950df1ac0c81a0d1c8ff3b6532f1f078897247e
|
Provenance
The following attestation bundles were made for nb2wb-0.2.4-py3-none-any.whl:
Publisher:
publish.yml on the-palindrome/nb2wb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nb2wb-0.2.4-py3-none-any.whl -
Subject digest:
407161cbf03f952d65764b6c65ee76d60c6d4a654ee0b2da25cf0e59cb43557b - Sigstore transparency entry: 1096863681
- Sigstore integration time:
-
Permalink:
the-palindrome/nb2wb@6e5bd42b2c4029f1d1cd0c614bfc18c28ee94b45 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/the-palindrome
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6e5bd42b2c4029f1d1cd0c614bfc18c28ee94b45 -
Trigger Event:
push
-
Statement type: