mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Merge pull request #5208 from Artie18/master
Fixed issue with word count for non ASCII letters.
This commit is contained in:
commit
c4a1ae2107
3 changed files with 9 additions and 2 deletions
|
@ -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/xml/xml.js');
|
||||||
app.import('bower_components/codemirror/mode/css/css.js');
|
app.import('bower_components/codemirror/mode/css/css.js');
|
||||||
app.import('bower_components/codemirror/mode/javascript/javascript.js');
|
app.import('bower_components/codemirror/mode/javascript/javascript.js');
|
||||||
|
app.import('bower_components/xregexp/xregexp-all.js');
|
||||||
|
|
||||||
module.exports = app.toTree();
|
module.exports = app.toTree();
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// jscs: disable
|
// jscs: disable
|
||||||
|
/* global XRegExp */
|
||||||
|
|
||||||
function wordCount(s) {
|
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(/<(.|\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(/(^\s*)|(\s*$)/gi, ''); // exclude starting and ending white-space
|
||||||
s = s.replace(/\n /gi, ' '); // convert newlines to spaces
|
s = s.replace(/\n /gi, ' '); // convert newlines to spaces
|
||||||
s = s.replace(/\n+/gi, ' ');
|
s = s.replace(/\n+/gi, ' ');
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
"nprogress": "0.1.6",
|
"nprogress": "0.1.6",
|
||||||
"rangyinputs": "1.2.0",
|
"rangyinputs": "1.2.0",
|
||||||
"showdown-ghost": "0.3.6",
|
"showdown-ghost": "0.3.6",
|
||||||
"validator-js": "3.39.0"
|
"validator-js": "3.39.0",
|
||||||
|
"xregexp": "2.0.0"
|
||||||
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue