fix(content): fix nbsp twig filter
This commit is contained in:
parent
9747dec1f9
commit
943ae7b63e
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue