Skip to content

Commit

Permalink
Merge pull request #5208 from Artie18/master
Browse files Browse the repository at this point in the history
Fixed issue with word count for non ASCII letters.
  • Loading branch information
ErisDS committed May 3, 2015
2 parents 7fe63b2 + 075c4fb commit 6244165
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/client/Brocfile.js
Expand Up @@ -59,5 +59,6 @@ app.import('bower_components/codemirror/mode/htmlmixed/htmlmixed.js');
app.import('bower_components/codemirror/mode/xml/xml.js');
app.import('bower_components/codemirror/mode/css/css.js');
app.import('bower_components/codemirror/mode/javascript/javascript.js');
app.import('bower_components/xregexp/xregexp-all.js');

module.exports = app.toTree();
7 changes: 6 additions & 1 deletion core/client/app/utils/word-count.js
@@ -1,7 +1,12 @@
// jscs: disable
/* global XRegExp */

function wordCount(s) {

var nonANumLetters = new XRegExp("[^\\s\\d\\p{L}]", "g"); // all non-alphanumeric letters regexp

s = s.replace(/<(.|\n)*?>/g, ' '); // strip tags
s = s.replace(/[^\w\s]/g, ''); // ignore non-alphanumeric letters
s = s.replace(nonANumLetters, ''); // ignore non-alphanumeric letters
s = s.replace(/(^\s*)|(\s*$)/gi, ''); // exclude starting and ending white-space
s = s.replace(/\n /gi, ' '); // convert newlines to spaces
s = s.replace(/\n+/gi, ' ');
Expand Down
3 changes: 2 additions & 1 deletion core/client/bower.json
Expand Up @@ -25,7 +25,8 @@
"nprogress": "0.1.6",
"rangyinputs": "1.2.0",
"showdown-ghost": "0.3.6",
"validator-js": "3.39.0"
"validator-js": "3.39.0",
"xregexp": "2.0.0"

},
"devDependencies": {
Expand Down

0 comments on commit 6244165

Please sign in to comment.