ExperimentalPure Zsh · HTML cleaning · v0.1.0

zoup

Keep the HTML a text browser can use.

zoup removes scripts, styles, and graphical clutter while keeping the document's useful structure. Written entirely in Zsh, it turns raw HTML into simpler HTML for a text browser or a downstream converter.

View on GitHub

Clean first, render later

Keep the useful HTML

Preserve semantic elements, links, tables, and supported form data. Images become their escaped alt text, and media fallback content stays readable.

Remove the visual layers

Drop scripts, styles, embedded frames, and unsupported subtrees. Strip classes, inline styles, event handlers, and graphical attributes.

Stay inside Zsh

Autoload the cleaner and return HTML directly into REPLY. Scalar input needs no modules or external programs; optional stdin input uses zsh/system.

Leave rendering to the reader

Return simplified HTML with its content order, whitespace, and character references intact. The consumer handles decoding, layout, and terminal styling.

Autoload and clean

Add the checkout's functions directory to fpath, then pass a literal HTML string. On success, the cleaned result replaces the caller's REPLY scalar.

fpath=( /path/to/zoup/functions "${fpath[@]}" )
autoload -Uz zoup

typeset REPLY
if zoup clean -- '<p>Hello <img src="photo.jpg" alt="world"></p><script>run()</script>'; then
  print -r -- "$REPLY"
fi
# <p>Hello world</p>

For files and pipelines, use the standalone launcher. Stdin input is buffered through EOF before cleaning.

zsh /path/to/zoup/bin/zoup clean --stdin < page.html > clean.html

One piece of the web pipeline

Pair zoup with zcurl for fetching and zhtml2md for Markdown output. zfetch brings those pieces together for MCP clients. zoup itself makes no network requests.

Current scope

Version 0.1.0 is a first, bounded implementation verified on Linux with Zsh 5.9.2. Input is limited to 1 MiB. It uses a tokenizer and allowlist, with a deliberately smaller parsing model than a full HTML5 browser. The output is intended for non-scripting text consumers, rather than insertion into a graphical browser as sanitized HTML.

Back to The Lab