Ghost/ghost/admin/utils/word-count.js
Hannah Wolfe 78088820d6 Ember cleanup: single quotes for JS
- All JS should use single quotes
2014-06-01 21:53:16 +01:00

6 lines
276 B
JavaScript

export default function (s) {
s = s.replace(/(^\s*)|(\s*$)/gi, ''); // exclude start and end white-space
s = s.replace(/[ ]{2,}/gi, ' '); // 2 or more space to 1
s = s.replace(/\n /, '\n'); // exclude newline with a start spacing
return s.split(' ').length;
}