Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c27b34a
Refs #24. No longer used
kylegibson-rldatix Jun 29, 2026
0439d2e
Refs #24. Initial flake8 config
kylegibson-rldatix Jun 29, 2026
45972c0
Refs #24. Initial GHA workflow for tests
kylegibson-rldatix Jun 29, 2026
befe7b8
Refs #24. Upgrade and use sha refs
kylegibson-rldatix Jun 29, 2026
b330bc1
Refs #24. Initial attempt at modernizing
kylegibson-rldatix Jun 29, 2026
d87f604
Refs #24. Upgrade and use sha refs
kylegibson-rldatix Jun 29, 2026
c9522f9
Refs #24. Drop to 92 since we don''t have full coverage right now
kylegibson-rldatix Jun 29, 2026
2fa8753
Refs #24. Update for pytest
kylegibson-rldatix Jun 29, 2026
acd16d0
Refs #24. Use raw string
kylegibson-rldatix Jun 29, 2026
9f310f8
Refs #24. Stop installing flake8 for the test env
kylegibson-rldatix Jun 29, 2026
3fc3732
Refs #24. Stop running lint for each python version
kylegibson-rldatix Jun 29, 2026
b45ae97
Refs #24. Fix some flake8 issues
kylegibson-rldatix Jun 29, 2026
60810ac
Refs #24. Rename so pytest can find it
kylegibson-rldatix Jun 29, 2026
d526c3a
Refs #24. Better formatting
kylegibson-rldatix Jun 29, 2026
2872792
Refs #24. Refactor, update for pytest
kylegibson-rldatix Jun 29, 2026
cbcc594
Refs #24. Updated coverage minimum to 99
kylegibson-rldatix Jun 30, 2026
2e9ee12
Refs #24. Move to pyproject
kylegibson-rldatix Jun 30, 2026
6b6453b
Refs #24. Pin requirements
kylegibson-rldatix Jun 30, 2026
613edf0
Refs #24. Improve case generation
kylegibson-rldatix Jun 30, 2026
4fec3dd
Refs #24. Fix a 16 year old bad test
kylegibson-rldatix Jun 30, 2026
d313a2f
Refs #24. Moved to tests folder
kylegibson-rldatix Jun 30, 2026
5bfe7bb
Refs #24. Fix import paths, move assert_* helpers to util
kylegibson-rldatix Jun 30, 2026
df9e9fb
Refs #24. Set coverage min to 98 and add a comment
kylegibson-rldatix Jun 30, 2026
44a7e93
Refs #24. Fix import
kylegibson-rldatix Jun 30, 2026
ccd8516
Refs #24. Create an issue for increasing coverage back to 100 and ref…
kylegibson-rldatix Jun 30, 2026
e7e89fc
Refs #24. Pull out test_util tests into a test test_util
kylegibson-rldatix Jun 30, 2026
45e7cfa
Refs #24. Coverage back at 99
kylegibson-rldatix Jun 30, 2026
c2973a7
Refs #24. Refactor
kylegibson-rldatix Jun 30, 2026
00ecc35
Refs #24. Removed duplicate test case and cleaned up a few noqa's
kylegibson-rldatix Jun 30, 2026
2e09e00
Refs #24. Cleaned up GHA triggers, added workflow_dispatch
kylegibson-rldatix Jun 30, 2026
b3cba3f
Refs #24. html5lib isn't actually used anymore
kylegibson-rldatix Jun 30, 2026
e7229c4
Refs #24. Drop push, pull_request is enough
kylegibson-rldatix Jun 30, 2026
0be29d1
Refs #24. Set lxml lower bound version
kylegibson-rldatix Jun 30, 2026
1cecf65
Refs #24. Test each major version of lxml across python 3.8, 3.10, 3.…
kylegibson-rldatix Jun 30, 2026
72c8e0e
Refs #24. Fixed spec def
kylegibson-rldatix Jun 30, 2026
d96e7f7
Refs #24. Stop hiding wheels
kylegibson-rldatix Jun 30, 2026
123480f
Refs #24. 4.2.5 support is still required but building from source on…
kylegibson-rldatix Jun 30, 2026
99e0edd
Refs #24. Converted to markdown and removed/updated stale references
kylegibson-rldatix Jun 30, 2026
6547505
Refs #24. Updated readme path
kylegibson-rldatix Jun 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im curious if you consideered going to pyproject.toml?

i know it adds an extra dependency for flake8 to have it read pyproject.toml ...

@kylegibson-rldatix kylegibson-rldatix Jun 30, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why, because it can't read pyproject natively

select = E,W,F
max-line-length = 95
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.8"
# 4.2.5 support is still required but building from source is slow
# and has missing dependencies, so we use a prebuilt wheel
lxml-spec: "vendor/lxml-4.2.5-cp38-cp38-linux_x86_64.whl"
# lxml v4
- python-version: "3.8"
lxml-spec: "lxml>=4,<5"
- python-version: "3.10"
lxml-spec: "lxml>=4,<5"
- python-version: "3.11"
lxml-spec: "lxml>=4,<5"
- python-version: "3.12"
lxml-spec: "lxml>=4,<5"
# lxml v5
- python-version: "3.8"
lxml-spec: "lxml>=5,<6"
- python-version: "3.10"
lxml-spec: "lxml>=5,<6"
- python-version: "3.11"
lxml-spec: "lxml>=5,<6"
- python-version: "3.12"
lxml-spec: "lxml>=5,<6"
# lxml v6
- python-version: "3.8"
lxml-spec: "lxml>=6,<7"
- python-version: "3.10"
lxml-spec: "lxml>=6,<7"
- python-version: "3.11"
lxml-spec: "lxml>=6,<7"
- python-version: "3.12"
lxml-spec: "lxml>=6,<7"
# lxml latest
- python-version: "3.12"
lxml-spec: "lxml"
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
Comment thread
kylegibson-rldatix marked this conversation as resolved.
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install "${{ matrix.lxml-spec }}"
pip install -r requirements/default.txt -r requirements/testing.txt
pip install -e .
- name: Run tests
run: pytest

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
Comment thread
kylegibson-rldatix marked this conversation as resolved.
with:
python-version: "3.12"
- run: pip install flake8
- run: flake8 htmltreediff
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ __pycache__/

build
dist
*.whl
*.egg-info
.tox
.workflow
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# HTML Tree Diff

Structure aware diff of XML and HTML documents.

The intended use is to concisely show the edits that have been made in a
document, so that authors of html content can review their work.


## What do we mean by "HTML Tree Diff"?

* **HTML:** The inputs to the diff function are HTML documents
* **Tree:** It considers the full XML tree structure of the inputs, not just text based changes.
* **Diff:** The output is human-readable HTML, using `<ins>` and `<del>` tags to show the changes.


## Command line interface

You can execute `htmltreediff.cli` directly as a python module, passing it html files to diff:

```
$ python -m htmltreediff.cli one.html two.html
<h1>
<del>
one
</del>
<ins>
two
</ins>
</h1>
```


## Python API

You can also use htmltreediff from within a python program as a library.

For HTML Changes:

```python
>>> from htmltreediff import diff
>>> print(diff('<h1>...one...</h1>', '<h1>...two...</h1>', pretty=True))
<h1>
...
<del>
one
</del>
<ins>
two
</ins>
...
</h1>
```

And also for text-only changes:

```python
>>> print(diff(
... 'The quick brown fox jumps over the lazy dog.',
... 'The very quick brown foxes jump over the dog.',
... plaintext=False,
... ))
The <ins>very </ins>quick brown <del>fox jumps</del><ins>foxes jump</ins> over the<del> lazy</del> dog.
```


## Running the unit tests

Use `pytest` to run the tests with coverage:

```shell
$ pip install -r requirements/testing.txt
$ pytest -v
```
74 changes: 0 additions & 74 deletions README.rst

This file was deleted.

4 changes: 1 addition & 3 deletions htmltreediff/diff_core.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import difflib
from xml.dom import Node

import six

from htmltreediff.lcs import matching_blocks_from_hashes
from htmltreediff.text import is_text_junk
from htmltreediff.util import (
Expand Down Expand Up @@ -277,7 +275,7 @@ def get_opcodes(matching_blocks):


def _is_junk(hashable_node):
if isinstance(hashable_node, six.string_types):
if isinstance(hashable_node, str):
return is_text_junk(hashable_node)
# Nodes with no text or just whitespace are junk.
for descendant in walk_dom(hashable_node.node):
Expand Down
Loading