Metadata-Version: 2.4
Name: JLDiff
Version: 1.0.0
Summary: Character by character diff script written in Python producing HTML output
Project-URL: Homepage, https://github.com/JEdward7777/JLDiff
Project-URL: Repository, https://github.com/JEdward7777/JLDiff
Project-URL: Bug Tracker, https://github.com/JEdward7777/JLDiff/issues
Author: Joshua Lansford
License-Expression: BSD-2-Clause
License-File: LICENSE
Keywords: character-diff,diff,html-diff,lcs,text-comparison
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: General
Requires-Python: >=3.6
Description-Content-Type: text/markdown

# JLDiff

Character by character diff script written in Python producing HTML output.

This uses the [Longest common subsequence algorithm](https://en.wikipedia.org/wiki/Longest_common_subsequence_problem) 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

```bash
pip install JLDiff
```

### From GitHub (development version)

```bash
# 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

```bash
# 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

```bash
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

```python
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](LICENSE) for details.
