mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-12-22 13:45:02 +00:00
feature-readingtime: improve algorithm by stripping markdown syntax
This commit is contained in:
parent
e7bdaed679
commit
b1381552f0
1 changed files with 5 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
register_module([
|
||||
"name" => "Reading time estimator",
|
||||
"version" => "0.1",
|
||||
"version" => "0.2",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Displays the approximate reading time for a page beneath it's title.",
|
||||
"id" => "feature-readingtime",
|
||||
|
@ -44,7 +44,10 @@ register_module([
|
|||
* @return array An array in the form [ low_time, high_time ] in minutes
|
||||
*/
|
||||
function estimate_reading_time(string $text, string $lang = "en") : array {
|
||||
$chars_count = mb_strlen($text);
|
||||
$chars_count = mb_strlen(preg_replace("/\s+?/", "", strtr($text, [
|
||||
"[" => "", "]" => "", "(" => "", ")" => "",
|
||||
"|" => "", "#" => "", "*" => ""
|
||||
])));
|
||||
$langs = [
|
||||
"en" => (object) [ "cpm" => 987, "variance" => 118 ],
|
||||
"ar" => (object) [ "cpm" => 612, "variance" => 88 ],
|
||||
|
|
Loading…
Reference in a new issue