From b37253d36d8e6aee949ea7110499127a48bdc4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Ho=CC=88rrmann?= Date: Thu, 16 Jun 2022 11:10:34 +0200 Subject: [PATCH] Document missing options Closes #12 and closes #13 --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/README.md b/README.md index fd5c673..38760d4 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,14 @@ $page ->filter('p[1]'); ``` +### $field->typographer()->options($options) + +Set options for the correction: + +- **`$options`:** An array of options to be passed to the corrections. + +See below for additional information. + # Additional field methods ## toDefinition() @@ -200,6 +208,66 @@ Actually, all that's need is hyphenation on long words that might overflow. Thus } ``` +Depending on your requirements, [vendor prefixes are needed to enable hyphenation](https://caniuse.com/?search=hyphen) in all browsers. Please also make sure to set the current language on your HTML nodes so that the correct dictionary is used by the browser. This can be done by specifying `lang` on your root `html` node, e. g. `…`. + +# Options + +Some corrections accept options for their transformations. You can either set options individually by calling the `options` method on the typographer object (see above) or you can define options globally by adding them to the Kirby configuration: + +```php +'hananils.typographer' => [ + 'options' => [ + // your options here + ] +] +``` + +## Quotes + +For the German language, the quotes correction allows you to toggle alternative quotes, known as "französische Anführungszeichen" or "Guillemets", instead of the usual "Gänsefüßchen": + +```php +'hananils.typographer' => [ + 'options' => [ + 'alternatives' => true // or 'guillemets' if you want to be more specific + ] +] +``` + +You can also pass this to you Typographer object directly: + +```php +$page + ->text() + ->typographer() + ->options([ + 'alternatives' => true + ]); +``` + +## Long words + +The correction that enables hyphenation of long words accepts an option for the word length. This is the minimum character count used to find long words: + +```php +'hananils.typographer' => [ + 'options' => [ + 'word-length' => 10 // the default is 15 + ] +] +``` + +You can also pass this to you Typographer object directly: + +```php +$page + ->text() + ->typographer() + ->options([ + 'word-length' => 10 + ]); +``` + # Inspiration and similar approaches There are a lot of different approaches to typography each suiting different needs, especially focussing on different languages. These libraries have been an inspiration for this plugin: