mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Merge pull request #5208 from Artie18/master
Fixed issue with word count for non ASCII letters.
This commit is contained in:
commit
c4a1ae2107
@ -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();
|
||||
|
@ -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, ' ');
|
||||
|
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user