fix(content): fix nbsp twig filter
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/deployment/woodpecker Pipeline was successful Details

This commit is contained in:
Simon Vieille 2023-01-16 00:04:39 +01:00
parent 9747dec1f9
commit 943ae7b63e
Signed by: deblan
GPG Key ID: 579388D585F70417
1 changed files with 9 additions and 7 deletions

View File

@ -17,12 +17,14 @@ class TypoExtension extends AbstractExtension
public function nbsp(string $value)
{
return preg_replace_callback(
'/(.+)(\.+|,+|;+|:+|!+|\?+)/isU',
function($d) {
return sprintf('%s %s', trim($d[1]), $d[2]);
},
$value
);
foreach (['!', '?', ':'] as $char) {
$value = str_replace(
sprintf(' %s', $char),
sprintf(' %s', $char),
$value
);
}
return $value;
}
}