Skip to content

About

Extract and search DjVu pages directly from your Typst documents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

typst-djvu

Typst package to extract the DjVu OCR/text layer page-by-page and locate anchors.

The djvu pure-Rust crate parses .djvu bytes, reads each page’s TXTz/TXTa layer, and joins pages with form-feed (\u{0C}), matching djvutxt. A wasm-minimal-protocol plugin exposes extract(bytes).

Public API

#import "@local/djvu:0.1.0": djvu-pages, djvu-find

#let data = read("book.djvu", encoding: none)
#let pages = djvu-pages(data)
#let pg = djvu-find(pages, "E.4.3", "Unique Stabilizing Solution") // 1-based or none
  • djvu-pages(data) — data is raw .djvu bytes; returns array(str) (one entry per page).
  • djvu-find(pages, ..needles) — first 1-based page where all substrings appear in order; pure Typst.

Local package install

Per Typst Local Packages, store this repo at {data-dir}/typst/packages/local/djvu/0.1.0 or pass --package-path to a parent of local/djvu/0.1.0.

Clone a tagged release (includes lib.typ, typst.toml, and djvu.wasm):

mkdir -p paper/packages/local/djvu
rm -rf paper/packages/local/djvu/0.1.0
git clone --depth 1 --branch v0.1.0 \
  https://github.com/F1uctus/typst-djvu \
  paper/packages/local/djvu/0.1.0

Or symlink a checkout:

ln -sf "$(pwd)/tools/typst-djvu" paper/packages/local/djvu/0.1.0

Compile with the package search path:

typst compile paper/thesis.typ paper/thesis.pdf \
  --root . \
  --package-path paper/packages

Build WASM

When Rust sources change, rebuild and commit djvu.wasm beside lib.typ:

cargo build --target wasm32-unknown-unknown --release
cp target/wasm32-unknown-unknown/release/djvu.wasm .

CI verifies the committed binary matches a fresh build.

Benchmark

djvu-find on cached djvu-pages output was benchmarked against Rust alternatives on the Kailath Linear Estimation DjVu. Results and harness live at git tag bench/kailath.

About

Extract and search DjVu pages directly from your Typst documents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages