Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word count: Adjust to count numbers as words #27288

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/wordcount/src/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const defaultSettings = {
'[',

// Basic Latin (extract)
'\u0021-\u0040\u005B-\u0060\u007B-\u007E',
'\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that it allows now digits from 0 to 9 👍🏻


// Latin-1 Supplement (extract)
'\u0080-\u00BF\u00D7\u00F7',
Expand Down
9 changes: 8 additions & 1 deletion packages/wordcount/src/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ describe( 'WordCounter', () => {
{
message: 'Punctuation.',
string: 'It’s two three \u2026 4?',
words: 3,
words: 4,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same sentence in Pages:
Screen Shot 2021-05-14 at 09 31 16

characters_excluding_spaces: 15,
characters_including_spaces: 19,
},
{
message: 'Numbers as word',
string: 'Should be 4 words',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick cross-check with Pages from Apple and it produces the same result:

Screen Shot 2021-05-14 at 09 29 45

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see also a comment from @Soean in #26339 (comment):

Good point, I tested Microsoft Word, Google Docs and Libre office, all apps count numbers as a word. So I think we should change it in WordPress

words: 4,
characters_excluding_spaces: 14,
characters_including_spaces: 17,
},
{
message: 'Em dash.',
string: 'one\u2014two--three',
Expand Down