Character by character diff script written in Python producing HTML output
Project description
JLDiff
Character by character diff script written in Python producing HTML output.
This uses the Longest common subsequence algorithm to do a true character-by-character comparison — no line-by-line preprocessing. The result is HTML with red and green coloring showing exactly what changed.
Note: Larger files take exponentially longer to process due to the nature of the algorithm.
Installation
From PyPI
pip install JLDiff
From GitHub (development version)
# With uv
uv pip install git+https://github.com/JEdward7777/JLDiff.git
# With pip
pip install git+https://github.com/JEdward7777/JLDiff.git
Run as a one-off CLI without installing
# From PyPI
uvx jldiff file1.txt file2.txt out.html
# From GitHub
uv run --from git+https://github.com/JEdward7777/JLDiff.git jldiff file1.txt file2.txt out.html
Usage
Command line
jldiff file1.txt file2.txt out.html [--same_size]
The --same_size flag keeps diff text the same size as surrounding text (by default, changed text is rendered larger for visibility).
As a library
from JLDiff import compute_diff, printDiffs
result = compute_diff("hello world", "hallo world", talk=False)
The compute_diff function takes two strings and returns a list of diff nodes. Each node has a .state (STATE_MATCH, STATE_PASSING_1ST, or STATE_PASSING_2ND) and a .content character. Set talk=False to suppress progress output to stdout.
Use printDiffs(result, output_file) to write the diff as HTML spans to a file-like object.
License
BSD 2-Clause — see LICENSE for details.
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 jldiff-1.0.0.tar.gz.
File metadata
- Download URL: jldiff-1.0.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dae6dd57f99dc00de466506d70193851ec9ebf52c0827abaf0e8c714bdc85a36
|
|
| MD5 |
37afbc70932e64588f61224baef2bce1
|
|
| BLAKE2b-256 |
ef637b3b7bb8ca06796f178a418c853b8519f0416a686e9d8ec9ec35b83056a3
|
Provenance
The following attestation bundles were made for jldiff-1.0.0.tar.gz:
Publisher:
publish.yml on JEdward7777/JLDiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jldiff-1.0.0.tar.gz -
Subject digest:
dae6dd57f99dc00de466506d70193851ec9ebf52c0827abaf0e8c714bdc85a36 - Sigstore transparency entry: 1374316809
- Sigstore integration time:
-
Permalink:
JEdward7777/JLDiff@73133c560ea2a63d614250c3f852673f99aab2bd -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/JEdward7777
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73133c560ea2a63d614250c3f852673f99aab2bd -
Trigger Event:
release
-
Statement type:
File details
Details for the file jldiff-1.0.0-py3-none-any.whl.
File metadata
- Download URL: jldiff-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6413fca9828bc61523c3f33bf2fd7b4ca5f5598a85b9d703e843ec260bab713
|
|
| MD5 |
5cea27cf663f205b55c6970a9dd4ab68
|
|
| BLAKE2b-256 |
8e41454602425fd9b38530e13e2e701257e1ab7e34d36613c4e7d4e159a0c7ee
|
Provenance
The following attestation bundles were made for jldiff-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on JEdward7777/JLDiff
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jldiff-1.0.0-py3-none-any.whl -
Subject digest:
f6413fca9828bc61523c3f33bf2fd7b4ca5f5598a85b9d703e843ec260bab713 - Sigstore transparency entry: 1374316955
- Sigstore integration time:
-
Permalink:
JEdward7777/JLDiff@73133c560ea2a63d614250c3f852673f99aab2bd -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/JEdward7777
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73133c560ea2a63d614250c3f852673f99aab2bd -
Trigger Event:
release
-
Statement type: