Skip to main content

Module diff

Module diff 

Source
Expand description

Block alignment and character-level diff used by miwa site --diff.

Structs§

BlockKey
A block with its comparison key and similarity text.
Row
One aligned row; indices point into the left / right block sequences.

Enums§

BlockKind
Kind of a rendered block.
Op
One edit-script operation over index ranges.
RowKind
Row classification in the side-by-side view.

Constants§

ABSORB_EQUAL_MAX
Maximum number of equal blocks absorbed between changes.
CHAR_DIFF_MAX_CHARS
Maximum combined chars for a character-level diff of a block pair.
DOC_MAX_BLOCKS
Maximum number of blocks per document before falling back.
MYERS_MAX_EDITS
Maximum edit distance accepted by Myers diff.
PAIRING_MAX_PRODUCT
Maximum product of deleted and added block counts for pairing.
SIMILARITY_THRESHOLD
Minimum similarity for pairing a deleted block with an added block.

Functions§

align_blocks
Aligns two block sequences per FR-117 (limits included).
char_marks
Character-level marks per FR-117: Some((changed_in_a, changed_in_b)) with one bool per char, or None when the pair exceeds CHAR_DIFF_MAX_CHARS or MYERS_MAX_EDITS (whole block changed, no highlight).
diff_ops
Myers diff. Returns None when the edit distance exceeds max_edits.
similarity
Multiset character overlap: 2 * common / (len_a + len_b). Both empty -> 1.0.