regex fixes
All checks were successful
lint / lint (push) Successful in 18s

This commit is contained in:
n 2024-02-25 18:36:26 +01:00
parent 1989307a67
commit f9780488a0
Signed by: n
GPG key ID: 510227DD6C502CE3
2 changed files with 3 additions and 7 deletions

View file

@ -15,7 +15,3 @@ $ git clone https://forge.tourmentine.com/n/shaarli-plugin-clickat.git path/to/s
- Threads with `@nic@threads.net`, - Threads with `@nic@threads.net`,
- Bluesky with `@nic.bsky.social`, - Bluesky with `@nic.bsky.social`,
- Fediverse with `@nic@instance`. - Fediverse with `@nic@instance`.
## Caveats
For now addresses need to be proceded by an empty space.

View file

@ -12,9 +12,9 @@ use Shaarli\Render\TemplatePage;
function hook_clickat_render_linklist($data) function hook_clickat_render_linklist($data)
{ {
$patterns = array( $patterns = array(
'/\ @([\w\d]+).bsky.social/' => ' <a href="https://bsky.app/profile/\1.bsky.social">&commat;\1.bsky.social</a>', '/([^\S]+)@([\w]+).bsky.social/' => ' <a href="https://bsky.app/profile/\2.bsky.social">&commat;\2.bsky.social</a>',
'/\ @([\w\d]+)@([\w\d_\-\.]+)/' => ' <a href="https://\2/@\1">&commat;\1</a>', '/([^\S]+)@([\w]+)@([\w_\-\.]+)/' => ' <a href="https://\3/@\2">&commat;\2</a>',
'/\ @([\w\d]+)/' => ' <a href="https://twitter.com/\1">&commat;\1</a>' '/([^\S]+)@([\w]+)/' => ' <a href="https://twitter.com/\2">&commat;\2</a>'
); );
foreach ($data['links'] as &$value) { foreach ($data['links'] as &$value) {
if (strpos($value['description'], ' @') !== false) { if (strpos($value['description'], ' @') !== false) {