typdiff-py
Python bindings for typdiff, a diff tool for Typst documents, similar to latexdiff for LaTeX.
typdiff compares two Typst source files and generates a new Typst document that visually highlights the differences — added text in blue with underline and deleted text in red with strikethrough. This package wraps the typdiff Rust crate directly via pyo3 (no subprocess, no separate binary to install) and ships prebuilt wheels for Linux (x86_64/aarch64/armv7/s390x/ppc64le), macOS, and Windows.
This is an independent, standalone project — the typdiff maintainer preferred to keep Python bindings out of the main repository, so they live here instead.
Installation
pip install typdiff
Usage
import typdiff
diff = typdiff.diff(old_bytes, new_bytes) # from bytes
diff = typdiff.diff_files("old.typ", "new.typ") # from file paths (str or Path)
diff() takes and returns bytes, matching how typst's compile() treats bytes as inline source (a plain str argument is instead treated as a path to read) — so typdiff's output can be passed straight into compile(). diff_files() still takes file paths as str/Path, since those are paths rather than document content.
Producing a PDF
Combine typdiff with typst (Python bindings for the Typst compiler, pip install typst) to go straight from two Typst files to a diff PDF, without shelling out to either CLI:
import typdiff
import typst
diff = typdiff.diff_files("old.typ", "new.typ")
pdf_bytes = typst.compile(diff)
Example
Given an old document:
= Introduction
This is the old text.
- First item
- Second item
== Details
The quick brown fox jumps over the lazy dog.
And a new document:
= Background
This is the new text.
- First item
- Third item
- Fourth item
== Details
The quick red fox leaps over the lazy cat.
typdiff.diff_files("old.typ", "new.typ") produces:
= #diff-deleted[Introduction]
= #diff-added[Background]
This is the #diff-deleted[old]#diff-added[new] text.
- First item
- #diff-deleted[Second]#diff-added[Third] item
- #diff-added[Fourth item]
== Details
The quick #diff-deleted[brown]#diff-added[red] fox #diff-deleted[jumps]#diff-added[leaps] over the lazy #diff-deleted[dog]#diff-added[cat].
See also
typdiff— the underlying Rust CLI and library.typst-py— Python bindings for Typst itself, used above to compile the diff output to a PDF.
License
Apache-2.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 typdiff-0.1.2.tar.gz.
File metadata
- Download URL: typdiff-0.1.2.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee1fd663546ad9a0a3a14b6257b6d49e3abb346acab5ac4d34cbeb6096339bbc
|
|
| MD5 |
b3fa56ccdfd377730e6573e9d5e4734c
|
|
| BLAKE2b-256 |
d2ebf0a11629a883f4bde90226a33f6f6f497baea2fc5a7b63a759a3f707b66d
|
Provenance
The following attestation bundles were made for typdiff-0.1.2.tar.gz:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2.tar.gz -
Subject digest:
ee1fd663546ad9a0a3a14b6257b6d49e3abb346acab5ac4d34cbeb6096339bbc - Sigstore transparency entry: 2533978662
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 319.7 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c2f412cc17c653fb76f6a0f934b2949aa47d77fcf07c3516a4a30c40676b7e5
|
|
| MD5 |
e7ed0e6d7727444e6223dcf4a49d5fc3
|
|
| BLAKE2b-256 |
542135d17e5f7e3c5d601a48fd158a92f647795207e77be39f3dae17745d80bf
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-win_amd64.whl -
Subject digest:
5c2f412cc17c653fb76f6a0f934b2949aa47d77fcf07c3516a4a30c40676b7e5 - Sigstore transparency entry: 2533978810
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 467.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86d7e0c3efda791770f1efd48c31c32b0e183909ae723a7210b3e67695a05f80
|
|
| MD5 |
46fe0d5b9152f26efc3b1c144e5c8458
|
|
| BLAKE2b-256 |
af6eebabd0067bcd28b2d12c5178dbe2a058ee48795d1eb262af1d852d1488da
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
86d7e0c3efda791770f1efd48c31c32b0e183909ae723a7210b3e67695a05f80 - Sigstore transparency entry: 2533978907
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 495.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bca8d3f9c37e5440991dcf35981e78ef47a89b758928f488cd061dc517d47f1a
|
|
| MD5 |
9bb353f7c584afc039d0403eaed7ebb6
|
|
| BLAKE2b-256 |
5673031982a7c3c482fe003c1fb284d99f4c86a5d47cc7220ba2aad618eae9fa
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl -
Subject digest:
bca8d3f9c37e5440991dcf35981e78ef47a89b758928f488cd061dc517d47f1a - Sigstore transparency entry: 2533978726
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 600.5 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40b435de0fae2bef84fc1e35ff9a8a425763b34c5d34d5d5951af581806ab0f4
|
|
| MD5 |
ea9921ce63a27a8f2c3951f3fad6fd25
|
|
| BLAKE2b-256 |
5f1f00d73620591d209d92ce50ae9d24349d14528608d009cec033f7dd605a09
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl -
Subject digest:
40b435de0fae2bef84fc1e35ff9a8a425763b34c5d34d5d5951af581806ab0f4 - Sigstore transparency entry: 2533978774
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 469.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6298ea3f64a6226bf7b4a71ebc26065c752dd2f400154718a231fa54fecfd2ba
|
|
| MD5 |
ac720572f6aa17cda3df96197583c904
|
|
| BLAKE2b-256 |
60b4357a648b364c6f837dc4bd2723cd1efc4d891c1a9cd9d2cf7e56d3c3bee6
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl -
Subject digest:
6298ea3f64a6226bf7b4a71ebc26065c752dd2f400154718a231fa54fecfd2ba - Sigstore transparency entry: 2533979062
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 453.6 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76afc9a68e1c585ef2161f66738d8d7e8e9626f3dfb349697f06dfe73aee5a93
|
|
| MD5 |
bf05d24a65e5fa9c20741f98b0605eee
|
|
| BLAKE2b-256 |
6500e59f2682611b1b0771bc68f9c024bdca0ffc01d41d2f3adef9315e8172ef
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
76afc9a68e1c585ef2161f66738d8d7e8e9626f3dfb349697f06dfe73aee5a93 - Sigstore transparency entry: 2533979008
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 415.4 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c1eb9f3be7357269f96e192b741c2a952a7993abdd95e3eea90de78a0744f6b
|
|
| MD5 |
76f970fdc4763fb1787cddc16e25efc0
|
|
| BLAKE2b-256 |
6322d0992da87a106005d30e7f44fc2ce75f3882626660e3b844be0f8f7673a9
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
9c1eb9f3be7357269f96e192b741c2a952a7993abdd95e3eea90de78a0744f6b - Sigstore transparency entry: 2533978852
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type:
File details
Details for the file typdiff-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: typdiff-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 421.4 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e1fa75c66d1f5544fc07f961faa6a95ecbebcc06f99d0fa64a52698458065b5
|
|
| MD5 |
2decd25caa9c7d488646770074fdc980
|
|
| BLAKE2b-256 |
2a61e282de0382d2ccce758264c7dfdba4075a6751edd591bbd4a219fec74c0d
|
Provenance
The following attestation bundles were made for typdiff-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on imphil/typdiff-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typdiff-0.1.2-cp38-abi3-macosx_10_12_x86_64.whl -
Subject digest:
8e1fa75c66d1f5544fc07f961faa6a95ecbebcc06f99d0fa64a52698458065b5 - Sigstore transparency entry: 2533978959
- Sigstore integration time:
-
Permalink:
imphil/typdiff-py@afd43c9657591e20ce83653e47cbf5916e38166f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/imphil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@afd43c9657591e20ce83653e47cbf5916e38166f -
Trigger Event:
push
-
Statement type: