Skip to content

SVG diffs graphically by default (issue #108) - #128

Merged
ivankovic merged 3 commits into
mainfrom
svg-graphical-diff
Nov 26, 2026
Merged

ivankovic merged 3 commits into
mainfrom
svg-graphical-diff

Conversation

@ivankovic

Copy link
Copy Markdown
Owner

Render SVGs

ivankovic and others added 3 commits November 26, 2026 10:08
A pair whose bytes sniff as SVG and whose trees usvg opens is now a
picture pair, compared by what it draws; an SVG usvg refuses falls back
to text. New diff/content/svg.rs renders with resvg, hardened against
SVG bombs: no filesystem hrefs, data: URLs only image/svg+xml and one
nesting level, capped at 1024. Headless and --mode json now carry SVG
pairs as picture content. In the TUI the picture viewer's `t` cycle
gains a "text" view for an SVG pair: its markup, diffed as text.

Four handmade picture fixtures pin the verdicts (attribute churn ->
invisible, circle added -> edited, recolor -> redrawn, SVG->PNG ->
invisible), the first cross-format pair in the corpus.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
- An SVG with text, a foreignObject, or an image other than one nested
  SVG drawn in full is no longer a picture: resvg is built without fonts
  or raster images, so such edits came out "invisible". It stays text.
- Headless and JSON keep the markup diff: a text pair that is content
  too gets the picture notice above its text diff, or `content` beside
  its hunks in JSON.
- Each SVG side is parsed once, cached by its bytes, and inside
  content::contained, so a parser panic during sniffing is an error.
- A small pair of SVGs is drawn up to 256 pixels by one factor, so a
  sub-pixel edit to an icon still shows.
- TUI: the markup view is diffed only when first shown, is named by the
  side that is present (an added SVG gets XML), and swallows picture
  keys; the member grid includes SVG members.
- picture.rs module doc rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUyLJ2enKeRdFnvjUTNwT1
The markup view test drew into 80x10, too short once its headers wrap
macOS's long temporary paths: the second change fell out of view. The
added-SVG tests read /dev/null, which Windows does not have; they use an
empty file, as git's absent side is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUyLJ2enKeRdFnvjUTNwT1
@ivankovic
ivankovic merged commit 2503843 into main Nov 26, 2026
21 checks passed
@ivankovic
ivankovic deleted the svg-graphical-diff branch November 26, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant