0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added support for all letters in word-count (not only ASCII) and added xregexp bower module to a project

This commit is contained in:
Artyom Fedenko 2015-05-02 22:56:33 +03:00
parent 8efd0cb4b5
commit 2687def400
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": {