package cascade

Build not yet checked
  1. Overview
  2. Docs
On This Page
  1. Utilities
CSS generation and manipulation library for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

cascade-1.3.0.tbz
sha256=6240100b1bc62f7e33f820fa3d7f23155f36f9c77d17a49de9e3559141414a08
sha512=3f9a8f7cabf16a09f063e5f807d74f0f9fac8ca1eda01b1873e67ac8289a37837341ae2db1a163ac7965a8360f1601dacdc3fba2d718857caef064827913b1e4

doc/cascade.diff/Cascade_diff/String_diff/index.html

Module Cascade_diff.String_diffSource

String difference analysis and formatting.

Sourceval default_max_width : int

default_max_width is the default maximum width for formatted output (60 characters).

Sourcetype config = {
  1. max_width : int;
    (*

    Maximum display width.

    *)
  2. short_threshold : int;
    (*

    Threshold below which strings are shown inline.

    *)
  3. show_caret : bool;
    (*

    Whether to display position indicators.

    *)
  4. indent : int;
    (*

    Left margin for position indicators.

    *)
}

Configuration for formatting.

Sourcetype t = {
  1. position : int;
    (*

    Character position of first difference.

    *)
  2. line_expected : int;
    (*

    1-based line of the difference in expected.

    *)
  3. column_expected : int;
    (*

    1-based byte column in expected.

    *)
  4. line_actual : int;
    (*

    1-based line of the difference in actual.

    *)
  5. column_actual : int;
    (*

    1-based byte column in actual.

    *)
  6. context_before : (string * string) list;
    (*

    Lines before difference.

    *)
  7. diff_lines : string * string;
    (*

    Lines containing the difference.

    *)
  8. context_after : (string * string) list;
    (*

    Lines after difference.

    *)
}

The type for string differences with context.

Sourceval diff : ?context_size:int -> expected:string -> string -> t option

diff ?context_size ~expected ~actual analyzes the difference between two strings. Returns None if strings are equal, otherwise returns detailed difference information with surrounding context lines. Default context_size is 3.

Sourceval pp : ?config:config -> ?expected_label:string -> ?actual_label:string -> Buffer.t -> t -> unit

pp ?config ?expected_label ?actual_label buf t pretty-prints a string diff in unified diff format with adaptive line formatting. Default labels are "Expected" and "Actual".

Utilities

Sourceval first_diff_pos : string -> string -> int option

first_diff_pos s1 s2 is the position of the first differing character, or None if the strings are equal.

Sourceval truncate_middle : int -> string -> string

truncate_middle max_len s truncates s to at most max_len characters, preserving both the beginning and end with ellipsis in the middle if truncation occurs.