From af1e8f89b3cc63651a54d1088e17d1e19f9626d1 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Tue, 20 Aug 2024 12:34:59 +0100 Subject: [PATCH] Document how diffSentences works, a bit (#542) --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 33d0629f..33f0c946 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,9 @@ Broadly, jsdiff's diff functions all take an old text and a new text and perform Returns a list of [change objects](#change-objects). -* `Diff.diffSentences(oldStr, newStr[, options])` - diffs two blocks of text, treating each sentence as a token. +* `Diff.diffSentences(oldStr, newStr[, options])` - diffs two blocks of text, treating each sentence as a token. The characters `.`, `!`, and `?`, when followed by whitespace, are treated as marking the end of a sentence; nothing else is considered to mark a sentence end. + + (For more sophisticated detection of sentence breaks, including support for non-English punctuation, consider instead tokenizing with an [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) with `granularity: 'sentence'` and passing the result to `Diff.diffArrays`.) Returns a list of [change objects](#change-objects).