Skip to content

Commit

Permalink
Document how diffSentences works, a bit (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
ExplodingCabbage authored Aug 20, 2024
1 parent fc5e7ea commit af1e8f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down

0 comments on commit af1e8f8

Please sign in to comment.