From 2c106590037f994f76149529e5a106d7d69c14bf Mon Sep 17 00:00:00 2001 From: Celestora Date: Mon, 18 Apr 2022 19:33:44 +0300 Subject: [PATCH] Change hashtag format to include danbooru tags as a subset Before: #kashim'a_(kantai_collection) -> #kashim'a_(kantai_collection) doesn't work Now: #kashim'a_(kantai_collection) -> (...) works --- Web/Models/Entities/Traits/TRichText.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Web/Models/Entities/Traits/TRichText.php b/Web/Models/Entities/Traits/TRichText.php index 791fb451..c8a85e70 100644 --- a/Web/Models/Entities/Traits/TRichText.php +++ b/Web/Models/Entities/Traits/TRichText.php @@ -64,7 +64,12 @@ trait TRichText $text = preg_replace("%@([A-Za-z0-9]++) \(((?:[\p{L&}\p{Lo} 0-9]\p{Mn}?)++)\)%Xu", "[$1|$2]", $text); $text = preg_replace("%([\n\r\s]|^)(@([A-Za-z0-9]++))%Xu", "$1[$3|@$3]", $text); $text = preg_replace("%\[([A-Za-z0-9]++)\|((?:[\p{L&}\p{Lo} 0-9@]\p{Mn}?)++)\]%Xu", "$2", $text); - $text = preg_replace("%([\n\r\s]|^)(#([\p{L}_-]++[0-9]*[\p{L}_-]*))%Xu", "$1$2", $text); + $text = preg_replace_callback("%([\n\r\s]|^)(\#([\p{L}_0-9][\p{L}_0-9\(\)\-\']+[\p{L}_0-9\(\)]|[\p{L}_0-9]{1,2}))%Xu", function($m) { + $slug = rawurlencode($m[3]); + + return "$m[1]$m[2]"; + }, $text); + $text = $this->formatEmojis($text); }