diff --git a/src/js/_enqueues/wp/utils/word-count.js b/src/js/_enqueues/wp/utils/word-count.js index 4c336582ecf63..dfafeaba72ec5 100644 --- a/src/js/_enqueues/wp/utils/word-count.js +++ b/src/js/_enqueues/wp/utils/word-count.js @@ -71,7 +71,7 @@ WordCounter.prototype.settings = { HTMLRegExp: /<\/?[a-z][^>]*?>/gi, HTMLcommentRegExp: //g, - spaceRegExp: / | /gi, + spaceRegExp: / | |[\u00A0\u2000-\u200A\u202F\u205F]/gi, HTMLEntityRegExp: /&\S+?;/g, // \u2014 = em-dash. diff --git a/tests/qunit/wp-admin/js/word-count.js b/tests/qunit/wp-admin/js/word-count.js index 5e5062a43c5dd..f59c01c0ba218 100644 --- a/tests/qunit/wp-admin/js/word-count.js +++ b/tests/qunit/wp-admin/js/word-count.js @@ -31,6 +31,27 @@ characters_excluding_spaces: 11, characters_including_spaces: 13 }, + { + message: 'No-break space.', + string: 'one\u00A0two\u00A0three', + words: 3, + characters_excluding_spaces: 11, + characters_including_spaces: 13 + }, + { + message: 'Unicode spaces.', + string: 'one\u2003two\u202Fthree', + words: 3, + characters_excluding_spaces: 11, + characters_including_spaces: 13 + }, + { + message: 'No-break space after an abbreviation.', + string: 'Dr.\u00A0Smith', + words: 2, + characters_excluding_spaces: 8, + characters_including_spaces: 9 + }, { message: 'Punctuation.', string: 'It\'s two three \u2026 4?',