Page MenuHomePhabricator

🧹 Calculate visible text diffs between two HTML documents (😅)
Open, Needs TriagePublic

Description

Write a Python module which takes an old and a new Parsoid HTML rendering and produces a human-readable diff (as well as a boolean "same / differs") of the text content.

  • Convert HTML to text. Normalize away whitespace or ignore in the diff.
  • Take the text difference between two documents, saving the changes as: boolean yes/no, list of changes, optionally as a rendered HTML file showing the text diff.
  • Write a script which runs this diff in each sample directory, writing HTML file outputs to files diffs/<wiki>/{old, new, diff}_<revid>.html.
  • Write NDJSON output file with lines containing: page ID, boolean yes/no, list of text changes

Out of scope:

  • Non-text diffs, for example HTML attributes or image alt text.

Event Timeline

awight renamed this task from Calculate visual diffs between two HTML documents to 🧹 Calculate visual diffs between two HTML documents.Jun 26 2026, 9:48 AM
  • Choose suitable Library for diff with mostly python native modules.
  • Return changes value for indirect value if not inner html changes and inner html changed return verdict if something changed.
  • Store everything in a single directory, rev, re-parsed rev and diff
  • Use Pytest to test everything.

Options:

Screenshot From 2026-06-30 12-21-45.png (1,820×421 px, 96 KB)

Screenshot From 2026-07-01 08-22-17.png (1,834×673 px, 83 KB)
This was doing better but still showed the commented out code as a diff
Flaws
Screenshot From 2026-06-30 12-16-38.png (1,820×421 px, 35 KB)

Screenshot From 2026-06-30 10-25-02.png (1,820×421 px, 164 KB)

Screenshot From 2026-07-01 08-11-08.png (2,134×651 px, 132 KB)

Screenshot From 2026-07-01 08-12-27.png (2,134×651 px, 73 KB)

Screenshot From 2026-07-01 08-25-15.png (1,834×673 px, 75 KB)

Also this returns a string of what changed exactly such as attributes and text

[insert, /div[1], p, 3]
[update-text, /div/p[2], "i", null]
[delete, /div/h2[1]]

also html

<div xmlns:diff="http://namespaces.shoobx.com/diff">
    <h1>Hello</h1>
    <h2 diff:delete="">Hello</h2>
    <p>Next something</p>
<diff:insert>    </diff:insert><p diff:insert="">i</p><diff:insert>
</diff:insert></div>
Lucyfediachambers renamed this task from 🧹 Calculate visual diffs between two HTML documents to 🧹 Calculate visual diffs between two HTML documents (😅).Jun 30 2026, 8:11 AM

We noticied this unfortunate difference, caused by unexplained Enterprise things: T430788: Enterprise snapshot rendering may be missing some MediaWiki extensions

DOM related diffs turned out to be inconsistent due to the DOM misalignment from the parsing html process which rendered it useless to the main goal.

The decision was to resort to visible text comparisons comparing two text blocks to find differences instead of relying on html. So the non-visible changes and changes in links or images will be done at a much later stage.

awight renamed this task from 🧹 Calculate visual diffs between two HTML documents (😅) to 🧹 Calculate visible text diffs between two HTML documents (😅).Jul 10 2026, 11:04 AM
awight updated the task description. (Show Details)

This has been run in production now!

Yippeee!