lez / word-diff

word based string diff library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not work with comma

giorgio79 opened this issue · comments

Tried

var diffs = worddiff.diffString(
  "Tom , reads novels but Jack reads comics .",
  "Tom reads novels , but Jack reads comics ."
);

console.log(diffs);

and I am getting

[ { text: 'Tom , reads novels but Jack reads comics .' } ]

Therefore no difference is detected...

That is something to do with

var out = this.diff(o.split(/\s+/), n.split(/\s+/));

it returns only words.

Instead it can use o.split(/\s+|\\W/)

>> "Tom reads novels , but Jack reads comics .".split(/\s+|\\W/)
>> (9) ['Tom', 'reads', 'novels', ',', 'but', 'Jack', 'reads', 'comics', '.']