text-visual-diff
    Preparing search index...

    Interface DiffTextResult

    Result of comparing HTML source against plain text.

    Each field provides a different view of the same comparison:

    • highlightedSource and highlightedTarget produce HTML strings with <mark> tags (or custom tags) wrapping matched, unmatched, and added regions, suitable for rendering in a browser.
    • extractedText and targetText are the plain-text inputs that were actually diffed after stripping HTML tags from the source.
    • segments is a machine-readable list of matched/unmatched regions in the source HTML, useful for building custom visualisations or analytics.
    • similarity is a 0–1 ratio indicating how similar the two inputs are.
    interface DiffTextResult {
        extractedText: string;
        highlightedSource: string;
        highlightedTarget: string;
        segments: HighlightSegment[];
        similarity: number;
        targetText: string;
    }
    Index

    Properties

    extractedText: string

    The plain text extracted from sourceHtml by stripping all tags.

    highlightedSource: string

    Source HTML with highlight tags wrapped around matched and unmatched text.

    highlightedTarget: string

    Target plain text with highlight tags wrapped around matched and added text.

    segments: HighlightSegment[]

    Structured segments describing each highlighted region in the source.

    similarity: number

    Dice coefficient indicating similarity between 0 (completely different) and 1 (identical). Computed as 2 * matchedChars / (sourceChars + targetChars).

    targetText: string

    The targetText argument, included for convenience.