Better Typography for your Kirby Site
“Better Typo” is a Kirby plugin tailored for enhancing typography especially for client-submitted content. It automatically transforms dumb quotes (""
/''
) into smart quotes, straight apostrophes ('
) into their curved equivalents and lots more. Automation in typography ensures consistency and professionalism without requiring manual intervention from designers.
The first option is to simply drag the better-typo
folder inside your site/plugins
folder.
The second option is to install “Better Typo” directly through the command line via Composer:
composer require simonlou/better-typo
Just add a ->bettertypo()
or ->bt()
to your chain which inputs the text you want to enhance.
For example:
$page->text()->bettertypo()
or
$page->text()->bt()
“Better Typo” is currently available for English and German. In your site/config/config.php
file you can specify which language you want to use (en
or de
). English is the default if you don’t add anything in your config.
It's really important to choose the right language because the corrections are different.
return [
'simonlou.better-typo.language' => 'de',
];
- Fixes double quotes:
""
→“”
(localized) - Fixes single quotes:
''
→‘’
(localized) - Fixes guillemets facing the wrong direction:
« … »
→» … «
(German) - Fixes apostrophes:
'
→’
- Fixes hyphens that are used as en dashes:
… - …
→… – …
- Fixes wrong multiplication signs:
X
/x
→×
- Adds thin space between number and unit:
1m
/1 m
→1 m
- Adds thin spaces before and after slash:
/
//
→/
- Fixes ellipsis:
...
→…
- Handle special cases like ’90s, ’Twas, Rock ’n’ Roll, etc.
- If there is only one dumb single quote in a string, it’s probably an apostrophe
- Track open/closed state while iterating over the text to make more informed decisions
- Handle double primes for inch
- Add non-breaking spaces
“Better Typo” is developed by Simon Lou (@simonlou@typo.social).
Thanks to Frank Rausch (@frankrausch@mastodon.social for the inspiration, he did a similar project for swift a few years back.
The “Better Typo” source code is released under the MIT License. Please view the LICENSE file for details.