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

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

View file

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