fix bug wordcount (#654)
parent
e1cffe7827
commit
eb2d49bfe4
|
@ -57,6 +57,9 @@ module.exports = function (hexo) {
|
|||
* Get the word count of a paragraph.
|
||||
*/
|
||||
hexo.extend.helper.register('word_count', function (content) {
|
||||
if (typeof(content) == "undefined") {
|
||||
return 0
|
||||
}
|
||||
content = content.replace(/<\/?[a-z][^>]*>/gi, '');
|
||||
content = content.trim();
|
||||
return content ? (content.match(/[\u00ff-\uffff]|[a-zA-Z]+/g) || []).length : 0;
|
||||
|
@ -103,4 +106,4 @@ module.exports = function (hexo) {
|
|||
hexo.extend.helper.register('hexo_version', function (data) {
|
||||
return hexo.version;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue