Expand description
Line-level text diffing for long text properties.
Produces structured diffs with context lines for human-readable comparison of instructions, descriptions, and other long text fields. Supports word-level highlighting within modified paragraphs.
Structs§
- Text
Diff Hunk - A group of contiguous diff lines with surrounding context.
- Text
Diff Result - Result of a line-level text diff.
- Word
Segment - A segment of a word-level diff within a single line.
Enums§
- Diff
Line - A single line in a text diff.
- Word
Segment Kind - Whether a word segment is unchanged or changed.
Constants§
- CONTEXT_
TRUNCATE_ LEN - Maximum display length for context lines before truncation.
- LONG_
TEXT_ THRESHOLD - Minimum string length to trigger line-level diffing.
Functions§
- diff_
text - Compute a line-level diff between two strings.
- diff_
words - Compute word-level diff segments between two strings.
- is_
long_ text - Returns
trueif the string is long enough or multi-line to warrant line-level diffing instead of inline comparison. - normalize_
for_ diff - Normalize text for more readable line-level diffs.
- truncate_
context - Truncate a string to approximately
max_lencharacters with" ... "in the middle.