From 6af52fb1619df7c2a6c6c2d573793b5d298ba798 Mon Sep 17 00:00:00 2001 From: iBug Date: Sat, 23 May 2020 02:03:57 +0800 Subject: [PATCH] Use new number_of_words plugin Thanks to @ashmaroli's help: https://github.com/jekyll/jekyll/pull/7813#issuecomment-632553598 --- _plugins/number_of_words.rb | 9 +++++++-- script/deploy-actions.sh | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/_plugins/number_of_words.rb b/_plugins/number_of_words.rb index 27535ad..8391e91 100644 --- a/_plugins/number_of_words.rb +++ b/_plugins/number_of_words.rb @@ -1,8 +1,13 @@ -CJK_REGEX = /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/ +CJK_CLASS = %!\p{Han}\p{Katakana}\p{Hiragana}\p{Hangul}! +CJK_REGEX = %r![#{CJK_CLASS}]!o +WORD_REGEX = %r![#{CJK_CLASS}\s]!o + module Jekyll module Filters def number_of_words input - input.scan(CJK_REGEX).length + input.gsub(CJK_REGEX, ' ').split.length + cjk_count = input.scan(CJK_REGEX).length + return input.split.length if cjk_count.zero? + cjk_count + input.scan(WORD_REGEX).length end end end diff --git a/script/deploy-actions.sh b/script/deploy-actions.sh index f890e6a..41f1a3e 100755 --- a/script/deploy-actions.sh +++ b/script/deploy-actions.sh @@ -18,7 +18,7 @@ e_info "Adding commit info" git config user.name "${GIT_USER:-GitHub}" git config user.email "${GIT_EMAIL:-noreply@github.com}" git add --all -git commit --message "${COMMIT_MSG}" --message "$source_msg" &>/dev/null +git commit --quiet --message "${COMMIT_MSG}" --message "$source_msg" e_info "Pushing to GitHub" SSH_AUTH_SOCK=none \