mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 09:35:28 +00:00
make description links clickable #30
This commit is contained in:
parent
ad5b075878
commit
6dcbd6de40
3 changed files with 23 additions and 3 deletions
|
|
@ -39,6 +39,13 @@ class AppExtension extends AbstractExtension
|
|||
'formatAgo'
|
||||
]
|
||||
),
|
||||
new TwigFilter(
|
||||
'url_to_markdown',
|
||||
[
|
||||
$this,
|
||||
'urlToMarkdown'
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -135,6 +142,17 @@ class AppExtension extends AbstractExtension
|
|||
}
|
||||
}
|
||||
|
||||
public function urlToMarkdown(
|
||||
string $text
|
||||
) : string
|
||||
{
|
||||
return preg_replace(
|
||||
'~(https?://(?:www\.)?[^\s]+)~i',
|
||||
'[$1]($1)',
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
||||
private function plural(int $number, array $texts)
|
||||
{
|
||||
$cases = [2, 0, 1, 1, 1, 2];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue