From 45d52b6fb21d22954d1b739f0cff70e2478d2aed Mon Sep 17 00:00:00 2001 From: Wang Ruochen Date: Wed, 1 Jan 2020 21:03:41 +0800 Subject: [PATCH] Use a plugin to calculate word count correctly Code taken from iBug. https://github.com/jekyll/jekyll/pull/7813 --- _plugins/number_of_words.rb | 8 ++++++++ _posts/2019-11-25-rust-wasm-closest-pair.md | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 _plugins/number_of_words.rb diff --git a/_plugins/number_of_words.rb b/_plugins/number_of_words.rb new file mode 100644 index 0000000..0c8616f --- /dev/null +++ b/_plugins/number_of_words.rb @@ -0,0 +1,8 @@ +module Jekyll + module Filters + def number_of_words input + cjk_regex = %r!\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}! + input.scan(cjk_regex).length + input.gsub(cjk_regex, ' ').split.length + end + end +end diff --git a/_posts/2019-11-25-rust-wasm-closest-pair.md b/_posts/2019-11-25-rust-wasm-closest-pair.md index bbb4679..949f66c 100644 --- a/_posts/2019-11-25-rust-wasm-closest-pair.md +++ b/_posts/2019-11-25-rust-wasm-closest-pair.md @@ -2,7 +2,6 @@ title: "Rust + WebAssembly: 最近点对问题" description: A Rust + WebAssembly demo of the closest point problem toc: true -read_time: false category: Programming tags: rust wasm redirect_from: /r/2