# 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`:

```php "/site/config/config.php"
return [
    'smartypants' => true
];
```

<warning>
Warning: There's currently an <a href="https://github.com/getkirby/kirby/issues/6344">unresolved issue</a> with the SmartyPants library. Using quotes in KirbyTag attributes can break HTML output.
</warning>

## Custom replacements

You can also override each of the default replacements:

```php "/site/config/config.php"
return [
    'smartypants' => [
        'doublequote.open'  => '&#8220;',
        'doublequote.close' => '&#8221;',
        //…
    ]
];
```

Here is a list of all default settings:

```php
return [
    'smartypants' => [
        'attr'                       => 1,
        'doublequote.open'           => '&#8220;',
        'doublequote.close'          => '&#8221;',
        'doublequote.low'            => '&#8222;',
        'singlequote.open'           => '&#8216;',
        'singlequote.close'          => '&#8217;',
        'backtick.doublequote.open'  => '&#8220;',
        'backtick.doublequote.close' => '&#8221;',
        'backtick.singlequote.open'  => '&#8216;',
        'backtick.singlequote.close' => '&#8217;',
        'emdash'                     => '&#8212;',
        'endash'                     => '&#8211;',
        'ellipsis'                   => '&#8230;',
        'space'                      => '(?: | |&nbsp;|&#0*160;|&#x0*[aA]0;)',
        'space.emdash'               => ' ',
        'space.endash'               => ' ',
        'space.colon'                => '&#160;',
        'space.semicolon'            => '&#160;',
        'space.marks'                => '&#160;',
        'space.frenchquote'          => '&#160;',
        'space.thousand'             => '&#160;',
        'space.unit'                 => '&#160;',
        'guillemet.leftpointing'     => '&#171;',
        'guillemet.rightpointing'    => '&#187;',
        'geresh'                     => '&#1523;',
        'gershayim'                  => '&#1524;',
        'skip'                       => 'pre|code|kbd|script|style|math',
    ]
];
```

## Language specific replacements

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/`.

```php "/site/config/config.php"
return [
    'smartypants' => true
];
```

```php "/site/languages/en.php"
<?php

return [
    'code' => 'en',
    'default' => true,
    'direction' => 'ltr',
    'locale' => 'en_US',
    'name' => 'English',
    'translations' => [],
    'url' => null,
    'smartypants' => [
        'doublequote.open'  => '&#8220;',
        'doublequote.close' => '&#8221;',
        //…
    ]
];
```