mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-09 06:27:56 +00:00
make description links clickable #30
This commit is contained in:
parent
ad5b075878
commit
6dcbd6de40
@ -15,6 +15,7 @@
|
||||
"doctrine/doctrine-migrations-bundle": "^3.2",
|
||||
"doctrine/orm": "^2.16",
|
||||
"jdenticon/jdenticon": "^1.0",
|
||||
"league/commonmark": "^2.4",
|
||||
"phpdocumentor/reflection-docblock": "^5.3",
|
||||
"phpstan/phpdoc-parser": "^1.24",
|
||||
"rhilip/bencode": "^2.3",
|
||||
@ -45,8 +46,9 @@
|
||||
"symfony/validator": "6.3.*",
|
||||
"symfony/web-link": "6.3.*",
|
||||
"symfony/yaml": "6.3.*",
|
||||
"twig/extra-bundle": "^2.12|^3.0",
|
||||
"twig/extra-bundle": "^3.7",
|
||||
"twig/intl-extra": "^3.7",
|
||||
"twig/markdown-extra": "^3.7",
|
||||
"twig/string-extra": "^3.7",
|
||||
"twig/twig": "^2.12|^3.0",
|
||||
"yggverse/scrapeer": "^0.5.4"
|
||||
|
@ -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];
|
||||
|
@ -226,7 +226,7 @@
|
||||
{{ 'Source' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
{{ file.source }}
|
||||
{{ file.source | url_to_markdown | markdown_to_html }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
@ -246,7 +246,7 @@
|
||||
{{ 'Comment' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
{{ file.comment | nl2br }}
|
||||
{{ file.comment | url_to_markdown | markdown_to_html }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user