Browse Source

add namespaceToMarkdown filter

main 1.4.0
ghost 11 months ago
parent
commit
b9458b91ba
  1. 22
      src/Twig/AppExtension.php

22
src/Twig/AppExtension.php

@ -52,6 +52,13 @@ class AppExtension extends AbstractExtension @@ -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 @@ -145,6 +152,10 @@ class AppExtension extends AbstractExtension
$text
);
$text = $this->namespaceToMarkdown(
$text
);
return $text;
}
@ -170,6 +181,17 @@ class AppExtension extends AbstractExtension @@ -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…
Cancel
Save