charIsSpaceOrSpecial fails to catch special characters
fvitali opened this issue · 1 comments
Dear all,
the regular expression on line 103 of hyphen.js
103 var charIsSpaceOrSpecial = /\s|[\!-\@\[-\
{-\xbf]/.test(nextChar); `
does not really work with all NON-WORD characters. For instance, in the provided Fiddle, by playing a little with the width of the Italian version of the result pane, you will notice that it breaks the line after an open quote, as follows:
giudizî s’
hanno a riferire
which is clearly wrong, but unfortunately the open quote character is not captured by the regular expression provided.
FIX
Following the suggestion in https://mathiasbynens.be/notes/es6-unicode-regex ,
I replaced the above-mentioned line 103 with the following:
103 var regExp = /[^\p{L}]/u ;
104 var charIsSpaceOrSpecial = regExp.test(nextChar);
and everything seems to work correctly.
I did not verify thoroughly, though.