Skip to content

Fix wrong quotation marks, apostrophes and hyphens in Kirby

License

Notifications You must be signed in to change notification settings

simonlouschueler/better-typo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Better Typo

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.

Installation

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

How to Use

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()

Language Configuration

“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',
];

Features

  • 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 m1 m
  • Adds thin spaces before and after slash: /// / 
  • Fixes ellipsis: ...‌…

To Do

  • 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

Credits

“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.

License

The “Better Typo” source code is released under the MIT License. Please view the LICENSE file for details.

About

Fix wrong quotation marks, apostrophes and hyphens in Kirby

Topics

Resources

License

Stars

Watchers

Forks

Languages