Skip to main content

ZimZipper

Package a folder (or a .zip) of Markdown / plain-text files — with images and LaTeX formulas — into one self-contained, offline, full-text-searchable ZIM archive you can read anywhere with Kiwix.

中文说明

What it does

  • Walks a directory (or extracts a .zip) and collects every .md, .markdown and .txt file.
  • Renders LaTeX ($...$, $$...$$, \(...\), \[...\]) to KaTeX HTML at build time, bundling KaTeX's CSS and fonts into the archive — so math displays correctly in Kiwix without JavaScript.
  • Embeds images (and other local assets) preserving the original directory layout, so relative links keep working.
  • Rewrites internal .md / .txt links to .html.
  • Generates an index page and standard ZIM metadata.
  • Builds an optional full-text search index (Xapian), so readers can search the content offline.

What it does NOT do

  • No incremental update inside a ZIM — the format is immutable; rebuild the archive when sources change (the whole pipeline is one command, so rebuilding is cheap to script).
  • No OCR — it packages text you already have, it does not turn scans into text.
  • No HTML scraping / crawling — point it at a local directory or .zip.
  • No .docx / .pdf ingestion — convert those to Markdown first.

Requirements

  • Python 3.9+
  • Node.js (for the bundled KaTeX renderer). If node is missing, math is left as raw LaTeX and everything else still works.
  • Python packages: libzim, markdown (installed automatically).

Installation

# From PyPI
pip install zimzipper

# From source
git clone https://github.com/CodeOfMe/ZimZipper.git
cd ZimZipper
pip install -e .

Quick Start

# Package a folder of notes
zimzipper build ./notes -o notes.zim

# Package a zip; set title and language
zimzipper build ./book.zip -o book.zim --title "My Book" --lang zho

# Skip the full-text index (faster, smaller)
zimzipper build ./notes -o notes.zim --no-fulltext

# Inspect an existing archive
zimzipper info notes.zim

Copy the resulting .zim to your phone and open it in the Kiwix app.

Usage

CLI

zimzipper [-V] [-v] [-o OUTPUT] [--json] [-q] <command> ...

Commands:
  build <src> [-o OUT.zim] [--title T] [--lang zho] [--no-fulltext] [--node node]
  info  <path.zim>

Python API

Every function returns a ToolResult, so you never need try/except.

from zimzipper import build_zim, inspect_zim

r = build_zim(src="./notes", out="notes.zim", title="My Notes", lang="zho")
print(r.success)          # True
print(r.data["pages"])    # number of documents
print(r.data["images"])   # number of embedded assets
print(r.data["size"])     # bytes

info = inspect_zim(path="notes.zim")
print(info.data["entries"])

Agent Integration (OpenAI Function Calling)

from zimzipper.tools import TOOLS, dispatch

# Pass TOOLS to your LLM's function-calling API
result = dispatch("zimzipper_build", {"src": "/data/notes", "out": "/data/notes.zim"})
print(result["success"])  # True

How it works

directory / .zip
      │  walk  (skip __MACOSX, .DS_Store, ._*)
      ▼
  .md / .txt ──► extract math ──► KaTeX (Node, batched) ──► HTML placeholders
      │                                                          │
      │            markdown -> HTML  ◄── substitute placeholders ─┘
      ▼
  pages + referenced images + katex.min.css & fonts
      ▼
  libzim Creator ──► single .zim  (optional Xapian full-text index)

Development

pip install -e ".[dev]"
pytest -q
ruff check zimzipper/
python -m build          # sdist + wheel

License

GPL-3.0-or-later.

Metadata

Release files for zimzipper 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zimzipper 0.0.3
File Size Uploaded
zimzipper-0.0.3.tar.gz 371.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zimzipper 0.0.3
File Interpreter ABI Platform
zimzipper-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 743.2 kB

Release files / zimzipper-0.0.3.tar.gz

Download URL zimzipper-0.0.3.tar.gz
Size 371.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4b75865617a5e65be928ee5167fe95b3dcc70416c3992ac48e48ab3934bf4829
BLAKE2b-256 checksum
How to use checksums
fb9d5526ee99bdf2bb9e4a89581ccbdfbfdcb9e2d8c65a5cf3f8ce6e8581d246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / zimzipper-0.0.3-py3-none-any.whl

Download URL zimzipper-0.0.3-py3-none-any.whl
Size 372.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2c9e3aa0d9d699ca7e5ccc7afb999bc1870f0b6e7ddbf513fa5ef940a03cc10
BLAKE2b-256 checksum
How to use checksums
941eead174e8cfb68a2ec678efaa7cbaeee0536b248308b7908028f8a7fcfc78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page