Typographist
    Preparing search index...

    Class Typographist<TCustomLocale>

    Applies selected symbolic text rules before soft hyphenation using registered locale data. Custom locale types can be inferred from configured plugins or declared as a generic union.

    import { Typographist } from '@elmenov-softworks/typographist';

    const typographist = new Typographist({ locale: 'ru' });
    typographist.format('машина');
    typographist.format('table', 'en'); // Uses English rules for this call only.

    Type Parameters

    • TCustomLocale extends string = never
    Index
    • Compiles and registers rules for the plugin's locale, replacing any previous registration. Successful registration clears cached words for all locales in this instance. Compilation or validation errors propagate and leave the previous rules and cached words intact.

      Parameters

      Returns void

    • Registers or atomically replaces a typography-only locale and clears the shared word cache. An explicit hyphenation category selection throws because no algorithm data is supplied.

      Parameters

      • definition: TextLocale<
            "es"
            | "fr"
            | "de"
            | "pt"
            | "it"
            | "en"
            | "ru"
            | "zh"
            | TCustomLocale,
        >

      Returns void

    • Formats text synchronously using the requested locale or the configured default. An override affects only this call. Unregistered locales throw by default, even for empty text. With unsupportedLocale preserve, valid unregistered locales return the exact source string. Preserves excluded words, recognized addresses, identifiers, unsupported words, and existing soft hyphens. With the same locale and configuration, bundled formatting leaves its own output unchanged; custom rules may not. Bundled rules preserve extra whitespace and supplied nonbreaking spaces; bindings require same-line content. Quote spacing uses narrow nonbreaking spaces by default for English and Russian. Reuses cached results for the same locale and exact source word when caching is enabled.

      Parameters

      • text: string
      • locale: "es" | "fr" | "de" | "pt" | "it" | "en" | "ru" | "zh" | TCustomLocale = ...

      Returns string

    • Reports whether rules are registered; validates and normalizes the locale without regional fallback.

      Parameters

      • locale: "es" | "fr" | "de" | "pt" | "it" | "en" | "ru" | "zh" | TCustomLocale

      Returns boolean

    • Removes registered rules and reports whether the locale was present. Clears cached words for all locales only when rules were removed. Removing the default locale makes calls without an override follow unsupportedLocale.

      Parameters

      • locale: "es" | "fr" | "de" | "pt" | "it" | "en" | "ru" | "zh" | TCustomLocale

      Returns boolean