DiffViewer API#
Bases: AnyWidget
Rich file diff viewer powered by @pierre/diffs.
Displays a side-by-side or unified diff between two file contents, with syntax-aware highlighting and dark mode support.
Examples:
diff = DiffViewer(
old_name="example.py",
old_contents="print('hello')",
new_name="example.py",
new_contents="print('world')",
)
diff
Create a DiffViewer widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old_name
|
str
|
Filename for the old version. |
''
|
old_contents
|
str
|
Text contents of the old version. |
''
|
new_name
|
str
|
Filename for the new version. |
''
|
new_contents
|
str
|
Text contents of the new version. |
''
|
diff_style
|
str
|
Diff display style, either |
'split'
|
expand_unchanged
|
bool
|
Show all unchanged lines instead of collapsing them. |
True
|
Source code in wigglystuff/diff_viewer.py
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
old_name |
str |
Filename for the old version. |
old_contents |
str |
Text contents of the old version. |
new_name |
str |
Filename for the new version. |
new_contents |
str |
Text contents of the new version. |
diff_style |
str |
"split" or "unified" (default: "split"). |
expand_unchanged |
bool |
Show all unchanged lines instead of collapsing them (default: True). |