Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jldiff-1.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jldiff-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

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

Hashes for jldiff-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dae6dd57f99dc00de466506d70193851ec9ebf52c0827abaf0e8c714bdc85a36
MD5 37afbc70932e64588f61224baef2bce1
BLAKE2b-256 ef637b3b7bb8ca06796f178a418c853b8519f0416a686e9d8ec9ec35b83056a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for jldiff-1.0.0.tar.gz:

Publisher: publish.yml on JEdward7777/JLDiff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for jldiff-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6413fca9828bc61523c3f33bf2fd7b4ca5f5598a85b9d703e843ec260bab713
MD5 5cea27cf663f205b55c6970a9dd4ab68
BLAKE2b-256 8e41454602425fd9b38530e13e2e701257e1ab7e34d36613c4e7d4e159a0c7ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for jldiff-1.0.0-py3-none-any.whl:

Publisher: publish.yml on JEdward7777/JLDiff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page