The Better Typography Plugin is an extension for Grav CMS. It automatically improves the typography of your content and provides a Twig filter.
Installing the Better Typography plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.
To install the plugin via the GPM, through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:
bin/gpm install better-typography
This will install the Better Typography plugin into your /user/plugins
-directory within Grav. Its files can be found under /your/site/grav/user/plugins/better-typography
.
To install the plugin manually, download the zip-version of this repository and unzip it under /your/site/grav/user/plugins
. Then rename the folder to better-typography
. You can find these files on GitHub or via GetGrav.org.
You should now have all the plugin files under
/your/site/grav/user/plugins/better-typography
NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its blueprints.yaml-file on GitHub.
If you use the Admin Plugin, you can install the plugin directly by browsing the Plugins
-menu and clicking on the Add
button.
Before configuring this plugin, you should copy the user/plugins/better-typography/better-typography.yaml
to user/config/plugins/better-typography.yaml
and only edit that copy.
Here is the default configuration and an explanation of available options:
enabled: true
perLanguageSettings:
- # You can add as many languages as defined as supported language in system.yaml
language: default #
useSmartQuotes: true # replace "foo" with “foo” or « foo »... Depends on the selected quoteStyle
smartQuotesStyle: doubleCurled # Style to apply for quotes ; available options are 'doubleCurled' (“foo”), 'doubleCurledReversed' (”foo”) 'doubleLow9' („foo”), 'doubleLow9Reversed' („foo“), 'singleCurled' (‘foo’), 'singleCurledReversed' (’foo’), 'singleLow9' (‚foo’), 'singleLow9Reversed' (‚foo‘), 'doubleGuillemetsFrench' (« foo »), 'doubleGuillemets' («foo»), 'doubleGuillemetsReversed' (»foo«), 'singleGuillemets' (‹foo›), 'singleGuillemetsReversed' (›foo‹) 'cornerBrackets' (「foo」), 'whiteCornerBracket' (『foo』).
smartQuotesStyleSecondary: singleCurled # same as above for smartQuotesStyle
useSmartDashes: true # replace -- & --- to en & em dashes, depending on the selected dashStyle
smartDashesStyle: international # 'international' or 'traditionalUS'
applyHyphenations: false
applyFrenchSpecific: false # apply specific french typographic rules such as unbreakable space before double punctuation (?, !, :, ;) and XVI<sup>e</sup> siècle
useSmartDiacritics: false # replace "creme brulee" with "crème brûlée". Only available for de-DE and en-US languages
smartDiacriticsLanguage: # de-DE or en-US
Note that if you use the Admin Plugin, a file with your configuration named better-typography.yaml will be saved in the user/config/plugins/
-folder once the configuration is saved in the Admin.
Once configured, the Better Typography will apply typographic improvements onto yout content, based on its language.
The Better TYpography plugin also provides a Twig filter bettertypo
which can be used in your skeletons:
{{ page.header.title|bettertypo }}
You can pass an argument to the bettertypo
Twig filter :
{{ page.header.title|bettertypo('default') }}
{{ page.header.title|bettertypo('fr') }}
The Better Typography plugin uses the PHP-Typography library released under the GNU General Public License v2.0.