mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
7 lines
315 B
JavaScript
7 lines
315 B
JavaScript
export default function (s) {
|
|
s = s.replace(/(^\s*)|(\s*$)/gi, ''); // exclude start and end white-space
|
|
s = s.replace(/[ ]{2,}/gi, ' '); // 2 or more space to 1
|
|
s = s.replace(/\n /gi, '\n'); // exclude newline with a start spacing
|
|
s = s.replace(/\n+/gi, '\n');
|
|
return s.split(/ |\n/).length;
|
|
} |