aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tools/Utils.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2019-01-07 10:17:29 +0100
committerGitHub <noreply@github.com>2019-01-07 10:17:29 +0100
commitd2aec7096dacfd72de13eddf146b3e2caa02c17a (patch)
tree197d4c6fba2c3c6fa63dfb53420aae61af769083 /src/Wallabag/CoreBundle/Tools/Utils.php
parent8f5c4b083ccf354e7942b4f50626de945d29aad7 (diff)
parent7f8630b91c1ef0a650bfe7cf422126187eb3c8f2 (diff)
downloadwallabag-d2aec7096dacfd72de13eddf146b3e2caa02c17a.tar.gz
wallabag-d2aec7096dacfd72de13eddf146b3e2caa02c17a.tar.zst
wallabag-d2aec7096dacfd72de13eddf146b3e2caa02c17a.zip
Merge pull request #3820 from lizyn/bugfix/incorrect-calculation-of-CJK-characters-in-reading-time-estimation
Fix incorrect reading time calculation for entries with CJK characters
Diffstat (limited to 'src/Wallabag/CoreBundle/Tools/Utils.php')
-rw-r--r--src/Wallabag/CoreBundle/Tools/Utils.php7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Tools/Utils.php b/src/Wallabag/CoreBundle/Tools/Utils.php
index 46bb1dc5..e56e251e 100644
--- a/src/Wallabag/CoreBundle/Tools/Utils.php
+++ b/src/Wallabag/CoreBundle/Tools/Utils.php
@@ -20,15 +20,14 @@ class Utils
20 } 20 }
21 21
22 /** 22 /**
23 * For a given text, we calculate reading time for an article 23 * For a given text, we calculate reading time for an article based on 200 words per minute.
24 * based on 200 words per minute.
25 * 24 *
26 * @param $text 25 * @param string $text
27 * 26 *
28 * @return float 27 * @return float
29 */ 28 */
30 public static function getReadingTime($text) 29 public static function getReadingTime($text)
31 { 30 {
32 return floor(\count(preg_split('~[^\p{L}\p{N}\']+~u', strip_tags($text))) / 200); 31 return floor(\count(preg_split('~([^\p{L}\p{N}\']+|(\p{Han}|\p{Hiragana}|\p{Katakana}|\p{Hangul}){1,2})~u', strip_tags($text))) / 200);
33 } 32 }
34} 33}