text-visual-diff
    Preparing search index...

    Function useDiffText

    • React hook that computes a diff between HTML source and plain text.

      The result is memoised and only recomputes when sourceHtml, targetText, or options change. See diffText for details on the return value.

      Parameters

      • sourceHtml: string

        HTML string whose visible text is compared.

      • targetText: string

        Plain text to compare against.

      • Optionaloptions: HighlightOptions

        Optional highlight configuration.

      Returns DiffTextResult

      A DiffTextResult with highlighted HTML, extracted text, and segments.

      import { useDiffText } from "text-visual-diff/react";

      function DiffView({ html, text }) {
      const result = useDiffText(html, text);
      return <div dangerouslySetInnerHTML={{ __html: result.highlightedSource }} />;
      }