|
|
@ -52,6 +52,20 @@ class AppExtension extends AbstractExtension |
|
|
|
'mentionToMarkdown' |
|
|
|
'mentionToMarkdown' |
|
|
|
] |
|
|
|
] |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
new TwigFilter( |
|
|
|
|
|
|
|
'url_to_html', |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
$this, |
|
|
|
|
|
|
|
'urlToHtml' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
new TwigFilter( |
|
|
|
|
|
|
|
'mention_to_html', |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
$this, |
|
|
|
|
|
|
|
'mentionToHtml' |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
), |
|
|
|
new TwigFilter( |
|
|
|
new TwigFilter( |
|
|
|
'keva_namespace_value', |
|
|
|
'keva_namespace_value', |
|
|
|
[ |
|
|
|
[ |
|
|
@ -170,6 +184,28 @@ class AppExtension extends AbstractExtension |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function urlToHtml( |
|
|
|
|
|
|
|
string $text |
|
|
|
|
|
|
|
): string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return preg_replace( |
|
|
|
|
|
|
|
'~(https?://(?:www\.)?[^\(\s\)]+)~i', |
|
|
|
|
|
|
|
'<a href="$1">$1</a>', |
|
|
|
|
|
|
|
$text |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function mentionToHtml( |
|
|
|
|
|
|
|
string $text |
|
|
|
|
|
|
|
): string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return preg_replace( |
|
|
|
|
|
|
|
'~@([A-z0-9]{64})~i', |
|
|
|
|
|
|
|
'<a href="#$1">@$1</a>', |
|
|
|
|
|
|
|
$text |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function plural(int $number, array $texts) |
|
|
|
private function plural(int $number, array $texts) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$cases = [2, 0, 1, 1, 1, 2]; |
|
|
|
$cases = [2, 0, 1, 1, 1, 2]; |
|
|
|