Merge pull request #5208 from Artie18/master

Fixed issue with word count for non ASCII letters.
This commit is contained in:
Hannah Wolfe 2015-05-03 18:23:33 +01:00
commit c4a1ae2107
3 changed files with 9 additions and 2 deletions

View File

@ -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();

View File

@ -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, ' ');

View File

@ -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": {