Search by

studio-variable / kirby-typography

isUnknown

French typography for Kirby: automatic non-breaking spaces on output and a visible non-breaking space button in the writer

Package info

forge.studio-variable.com/studio-variable/kirby-typography.git

Homepage

Issues

Type:kirby-plugin

pkg:composer/studio-variable/kirby-typography

Statistics

Installs: 21

Dependents: 1

Suggesters: 0

v1.0.1 2026-11-26 11:22 UTC

This package is auto-updated.

Last update: 2026-11-26 11:26:15 UTC


README

French typography for Kirby: non-breaking spaces added automatically on output, and a non-breaking space button in the writer that keeps them visible in the Panel.

Requirements • Installation • Usage • Rules • Panel • Configuration • Credits • License

Requirements

  • Kirby 5 or 6
  • PHP 8.2+

Installation

Composer (recommended)

composer require studio-variable/kirby-typography

Manual installation

Download the repository and copy it to site/plugins/typography.

Usage

Call typography() on the HTML you output:

<?= $page->text()->kirbytext()->typography() ?>
<?= $page->text()->toBlocks()->typography() ?>
<?= $page->title()->esc()->typography() ?>

The field method returns a field, so it chains with other field methods. The blocks method returns the rendered HTML. StudioVariable\Typography\Typography::apply($html) works on any string.

Only text is changed: tags, attributes, comments and the content of script, style, pre, code, kbd, samp and textarea are left untouched. The stored content never changes, and applying the rules twice gives the same result.

Rules

RuleEffect
punctuationNarrow non-breaking space before ; ! ?, non-breaking space before : and inside « »
numbersNarrow non-breaking space as thousands separator (12 000), non-breaking space between a number and what follows (35 %, 3 ateliers)
articlesBinds un, une, le, la, les, du, des, au, aux to the next word
determinersBinds ce, cette, mon, ma, ses, notre, leurs… to the next word
pronounsBinds je, tu, il, elle, on, nous, vous, ils, elles to the next word
conjunctionsBinds mais, ou, où, et, donc, or, ni, car, que to the next word
shortPrepositionsBinds à, y, en, de, sur, par to the next word
prepositionsBinds après, avant, avec, chez, dans, pour, sans, sous, vers… to the next word
shortWordsBinds any word of one or two letters to the next word
emphasisKeeps an em, strong, b or i of up to three words on one line
dashesBinds an en or em dash to the next word
widowsBinds the last two words of a paragraph, heading, list item or cell, when they are short enough

Spaces and &nbsp; already next to each other are merged into one non-breaking space.

Panel

The text block gets a non-breaking space button, also available with Cmd/Ctrl + Shift + Space. To add it to a writer field, list nbsp in its marks:

text:
  type: writer
  marks:
    - bold
    - italic
    - link
    - nbsp

Non-breaking spaces (and narrow ones) are shown with a light grey background in writer, textarea and text fields. The background comes from a small font limited to these two characters, so the content itself is not changed. A project's own site/blueprints/blocks/text.yml replaces the plugin's one: add nbsp to its marks to keep the button.

The font is built by tools/build-font.py (requires fonttools and brotli), which writes index.css from tools/index.css.

Configuration

KeyTypeDefaultDescription
studio-variable.typography.rulesarrayevery rule trueRules to apply, see Rules: set one to false to turn it off
studio-variable.typography.exceptionsarray[]Words never bound to the next one, case-insensitive
return [
    'studio-variable.typography.rules' => [
        'shortWords' => false,
        'widows' => false,
    ],
    'studio-variable.typography.exceptions' => ['or'],
];

Translations

The button label is translated in English and French.

Credits

The word rules are inspired by ragadjust by Nathan Ford and its French adaptation ragadjustfr by Yann Trividic and Nicolas Taffin.

License

MIT License © 2026 Studio Variable