PHPackages                             yepteam/typograph - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yepteam/typograph

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yepteam/typograph
=================

PHP-библиотека для типографической обработки текста.

v1.7.3(4w ago)2112MITPHPPHP &gt;=8.1.0CI passing

Since May 9Pushed 4w ago2 watchersCompare

[ Source](https://github.com/yepteam/typograph)[ Packagist](https://packagist.org/packages/yepteam/typograph)[ RSS](/packages/yepteam-typograph/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (3)Versions (42)Used By (0)

PHP-библиотека для типографической обработки текста.

[![License](https://camo.githubusercontent.com/43ecdc8516ae1b2fce4f76f9b73a0cde5c6d5356ed492082cd42ee8dd4369f24/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7965707465616d2f7479706f6772617068)](https://camo.githubusercontent.com/43ecdc8516ae1b2fce4f76f9b73a0cde5c6d5356ed492082cd42ee8dd4369f24/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7965707465616d2f7479706f6772617068)[![Packagist Version](https://camo.githubusercontent.com/814a3eaf2346a2c4d99fd71b84c7528bdf5ffbd6fb56a7fd1f4515b5a8ceb2dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7965707465616d2f7479706f6772617068)](https://camo.githubusercontent.com/814a3eaf2346a2c4d99fd71b84c7528bdf5ffbd6fb56a7fd1f4515b5a8ceb2dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7965707465616d2f7479706f6772617068)[![PHP Version](https://camo.githubusercontent.com/317dc0f5a901b3e940bf11aaa333593995e208147e94270e6805cf18b4272e4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7965707465616d2f7479706f6772617068)](https://camo.githubusercontent.com/317dc0f5a901b3e940bf11aaa333593995e208147e94270e6805cf18b4272e4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7965707465616d2f7479706f6772617068)[![Packagist Downloads](https://camo.githubusercontent.com/6c4f8171b8439a92c6335d3b374fb976ff113253250d8934b50bda00f3e08243/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7965707465616d2f7479706f6772617068)](https://camo.githubusercontent.com/6c4f8171b8439a92c6335d3b374fb976ff113253250d8934b50bda00f3e08243/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7965707465616d2f7479706f6772617068)

Возможности
-----------

[](#возможности)

- Замена пробелов и дефисов на неразрывные
- Расстановка короткого и длинного тире
- Замена кавычек первого и второго уровня
- Игнорирование HTML-тегов, Emoji, содержимого тегов script, style и pre
- Кодирование символов в виде мнемоник или числовых кодов

Требования
----------

[](#требования)

- PHP 8.1 или выше
- Расширение `mbstring`

Установка
---------

[](#установка)

Установите пакет через composer:

```
composer require yepteam/typograph
```

Использование
-------------

[](#использование)

```
use Yepteam\Typograph\Typograph;

// Инициализация со стандартными параметрами
$typograph = new Typograph();

$html = $typograph->format($html);
```

Конструктор также принимает булев флаг — короткую форму выбора режима кодирования:

```
new Typograph(true);  // готовыми символами (raw)
new Typograph(false); // буквенными кодами (named)
```

Конфигурация
------------

[](#конфигурация)

В примере ниже указаны параметры по умолчанию.

```
$typograph = new Typograph([
    // Режим кодирования
    // named - буквенными кодами
    // numeric - числовыми кодами
    // hex - шестнадцатеричными кодами
    // raw - готовыми символами
    'entities' => Typograph::ENTITIES_RAW,

    // Многоточия
    // hellip - замена трех точек на символ многоточия
    // dots - замена символа многоточия на три точки
    // none - не обрабатывать многоточия
    'ellipsis' => Typograph::ELLIPSIS_HELLIP,

    // Массив кавычек по каждому уровню
    // При пустом массиве обработка кавычек будет отключена
    'quotes' => [
        ['«', '»'], // кавычки 1 уровня
        ['„', '“'], // кавычки 2 уровня
    ],

    // Правила* замены знаков минус/дефис/тире
    'dash' => [
        'hyphen-to-mdash' => true, // дефис на mdash
        'hyphen-to-minus' => true, // дефис на минус
        'mdash-to-ndash'  => true, // mdash на ndash
        'ndash-to-mdash'  => true, // ndash на mdash
        'hyphen-to-nbhy'  => true, // дефис на неразрывный
    ],

    // Правила* расстановки неразрывных пробелов
    'nbsp' => [
        'initial'    => true, // до и после инициалов
        'mdash'      => true, // до и после тире
        'number'     => true, // до и после числа
        'short-word' => true, // до и после короткого слова
    ],

    // Правила* обработки специальных символов
    'special' => [
        'copyright'  => true, // (C) на ©
        'plus-minus' => true, // +- на ±
        'reg-mark'   => true, // (R) на ®
        'times'      => true, // x на × между числами
        'trade'      => true, // (rm) на ™
    ],

    // Режим отладки правил
    'debug' => false,
]);
```

\*Для отключения группы правил укажите пустой массив, false или null.

Метрики
-------

[](#метрики)

После вызова `format()` доступны метрики последней обработки:

```
$typograph->format($html);

$metrics = $typograph->getMetrics();
// [
//     'originalContentLength' => 1234,  // длина исходного текста (символов)
//     'resultContentLength'   => 1256,  // длина результата (символов)
//     'tokenizationTime'      => 0.001, // время токенизации (сек)
//     'processingTime'        => 0.004, // время применения правил (сек)
//     'totalTime'             => 0.005, // суммарное время (сек)
//     'memoryUsage'           => 524288 // использование памяти (байт)
// ]
```

Дополнительные методы
---------------------

[](#дополнительные-методы)

```
// Изменить параметры у существующего экземпляра
$typograph->setOptions(['entities' => Typograph::ENTITIES_NAMED]);

// Получить текущие параметры и параметры по умолчанию
$typograph->getOptions();
$typograph->getDefaultOptions();

// Получить массив токенов после обработки (удобно вместе с 'debug' => true)
$typograph->getTokens();
```

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance94

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~35 days

Total

41

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e75679a5e27739b9f3187d96dd0fe492102f9f3fe58a94c787b0f09d4f1f11b0?d=identicon)[arthurshlain](/maintainers/arthurshlain)

---

Top Contributors

[![arthurshlain](https://avatars.githubusercontent.com/u/2047645?v=4)](https://github.com/arthurshlain "arthurshlain (133 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yepteam-typograph/health.svg)

```
[![Health](https://phpackages.com/badges/yepteam-typograph/health.svg)](https://phpackages.com/packages/yepteam-typograph)
```

###  Alternatives

[webdevstudios/cpt-core

WordPress Custom Post Type OO wrapper

807.7k1](/packages/webdevstudios-cpt-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
