smartypants
Convert typical text formatting issues into a typographically correct version
Enable SmartyPants
When you activate SmartyPants in your config, SmartyPants rules are automatically applied whenever you use the ->kirbytext()
or ->smartypants()
field methods.
To enable SmartyPants, you can set the smartypants
option to true
:
return [
'smartypants' => true
];
Custom replacements
You can also override each of the default replacements:
return [
'smartypants' => [
'doublequote.open' => '“',
'doublequote.close' => '”',
//…
]
];
Here is a list of all default settings:
return [
'smartypants' => [
'attr' => 1,
'doublequote.open' => '“',
'doublequote.close' => '”',
'doublequote.low' => '„',
'singlequote.open' => '‘',
'singlequote.close' => '’',
'backtick.doublequote.open' => '“',
'backtick.doublequote.close' => '”',
'backtick.singlequote.open' => '‘',
'backtick.singlequote.close' => '’',
'emdash' => '—',
'endash' => '–',
'ellipsis' => '…',
'space' => '(?: | | |�*160;|�*[aA]0;)',
'space.emdash' => ' ',
'space.endash' => ' ',
'space.colon' => ' ',
'space.semicolon' => ' ',
'space.marks' => ' ',
'space.frenchquote' => ' ',
'space.thousand' => ' ',
'space.unit' => ' ',
'guillemet.leftpointing' => '«',
'guillemet.rightpointing' => '»',
'geresh' => '׳',
'gershayim' => '״',
'skip' => 'pre|code|kbd|script|style|math',
]
];
Language specific replacements
Since 3.3.0
To use language specific replacements, you have to enable the smartypants
option in your config and then add your array of options to each language file in /site/languages/
.
return [
'smartypants' => true
];
<?php
return [
'code' => 'en',
'default' => true,
'direction' => 'ltr',
'locale' => 'en_US',
'name' => 'English',
'translations' => [],
'url' => null,
'smartypants' => [
'doublequote.open' => '“',
'doublequote.close' => '”',
//…
]
];