mirror of
https://github.com/kevachat/webapp.git
synced 2025-01-23 04:54:32 +00:00
add namespaceToMarkdown filter
This commit is contained in:
parent
6f06dd52d7
commit
b9458b91ba
@ -52,6 +52,13 @@ class AppExtension extends AbstractExtension
|
||||
'mentionToMarkdown'
|
||||
]
|
||||
),
|
||||
new TwigFilter(
|
||||
'namespace_to_markdown',
|
||||
[
|
||||
$this,
|
||||
'namespaceToMarkdown'
|
||||
]
|
||||
),
|
||||
new TwigFilter(
|
||||
'keva_namespace_value',
|
||||
[
|
||||
@ -145,6 +152,10 @@ class AppExtension extends AbstractExtension
|
||||
$text
|
||||
);
|
||||
|
||||
$text = $this->namespaceToMarkdown(
|
||||
$text
|
||||
);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
@ -170,6 +181,17 @@ class AppExtension extends AbstractExtension
|
||||
);
|
||||
}
|
||||
|
||||
public function namespaceToMarkdown(
|
||||
string $text
|
||||
): string
|
||||
{
|
||||
return preg_replace(
|
||||
'~(N[A-z0-9]{33})~i',
|
||||
'[$1]($1)',
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
||||
private function plural(int $number, array $texts)
|
||||
{
|
||||
$cases = [2, 0, 1, 1, 1, 2];
|
||||
|
Loading…
x
Reference in New Issue
Block a user