Skip to content

Commit 06b6ff6

Browse files
committed
Added note to readme about Intl.Segmenter.
1 parent 4cfcbb6 commit 06b6ff6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ tags or tag hierarchies.
1515

1616
The exports can be found in [`dist/htmldiff.d.ts`](https://github.com/Sedeniono/htmldiff.js/blob/master/dist/htmldiff.d.ts).
1717

18-
### `diff` function
19-
18+
The main exported function is:
2019
```TS
2120
function diff(before: string, after: string, className?: string, dataPrefix?: string);
2221
```
@@ -36,8 +35,12 @@ of these parameters it will be ignored:
3635
the default attribute name `data-operation-index` will be added on every inserted
3736
`<ins>` and `<del>` tag. The value of this attribute is an auto incremented counter.
3837

38+
Note that for better support of languages that do not use spaces between words (e.g. Japanese),
39+
the code relies on the [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) API, which is available in all major browsers since 2024.
40+
If it is not available, the library falls back to separating words only by whitespace.
41+
3942

40-
### Example
43+
## Example
4144

4245
TypeScript:
4346

0 commit comments

Comments
 (0)