Manuscript Documentation
v2026.12.0

@std/data/diff.ms#

Import each required symbol with import Name from "@std/data/diff.ms".

CloseMatchesOptions Type#

Settings for close_matches.

Manuscript
type CloseMatchesOptions {
    limit Int = 3
    cutoff Float = 0.6
}

CloseMatchesOptions.cutoff#

Minimum similarity_ratio from 0.0 to 1.0; at or below 0.0 keeps every candidate and above 1.0 keeps none.

Manuscript
cutoff Float = 0.6

CloseMatchesOptions.limit#

Maximum candidates returned; zero or below returns none.

Manuscript
limit Int = 3

UnifiedDiffOptions Type#

Settings for unified_diff.

Manuscript
type UnifiedDiffOptions {
    context Int = 3
    old_name String = "a"
    new_name String = "b"
}

UnifiedDiffOptions.context#

Unchanged lines kept around each change; below zero counts as zero.

Manuscript
context Int = 3

UnifiedDiffOptions.new_name#

Label of the +++ header.

Manuscript
new_name String = "b"

UnifiedDiffOptions.old_name#

Label of the --- header.

Manuscript
old_name String = "a"

close_matches Function#

Returns up to options.limit candidates whose similarity_ratio with word is at least options.cutoff, best match first; ties keep the candidates’ order. Example: close_matches("appel", ["ape", "apple", "peach"], CloseMatchesOptions(limit: 2)) is ["apple", "ape"].

Manuscript
fn close_matches(word String, candidates List[String], options CloseMatchesOptions = CloseMatchesOptions()) List[String] { ... }

edit_distance Function#

Returns the number of single-scalar insertions, deletions and substitutions that turn left into right (Levenshtein distance). Example: edit_distance("kitten", "sitting") is 3; equal strings give 0.

Manuscript
fn edit_distance(left String, right String) Int { ... }

similarity_ratio Function#

Returns how alike two strings are, from 0.0 (nothing shared) to 1.0 (equal): twice the length of their longest common subsequence of scalars, divided by the total length. Two empty strings give 1.0. Use close_matches to rank a list of candidates by this score. Example: similarity_ratio("abcd", "abd") is about 0.857.

Manuscript
fn similarity_ratio(left String, right String) Float { ... }

unified_diff Function#

Compares two lists of lines and returns the differences in unified diff format, or an empty string when the lists are equal. Input lines carry no trailing newline. Each output line, including the last, ends with “\n”. Example: unified_diff(["a", "b"], ["a", "c"], UnifiedDiffOptions(context: 1)) is "--- a\n+++ b\n@@ -1,2 +1,2 @@\n a\n-b\n+c\n".

Manuscript
fn unified_diff(old List[String], new List[String], options UnifiedDiffOptions = UnifiedDiffOptions()) String { ... }