richtypo-rules-ru
TypeScript icon, indicating that this package has built-in type declarations

5.1.3 • Public • Published

Richtypo Russian typography rules

The Russian typography rules for Richtypo.

Converts this:

Настругал Папа Карло тысячу БУРАТИН 29 февраля - используйте
"Ричтайпо" и ваши уши будут торчать из-за туч.

to this:

Настругал Папа Карло тысячу
<abbr>БУРАТИН</abbr> 29&nbsp;февраля&nbsp;— используйте «Ричтайпо»
и&nbsp;ваши уши будут торчать <nobr>из-за</nobr>&nbsp;туч.

Installation

npm install --save richtypo richtypo-rules-ru

Basic usage

import richtypo from 'richtypo';
import rules from 'richtypo-rules-ru';

const text =
  'Настругал Папа Карло тысячу БУРАТИН 29 февраля - ' +
  'используйте "Ричтайпо" и ваши уши будут торчать из-за туч.';

richtypo(rules, text);

// -> Настругал Папа Карло тысячу <abbr>БУРАТИН</abbr> 29&nbsp;февраля&nbsp;—
//    используйте «Ричтайпо» и&nbsp;ваши уши будут торчать <nobr>из-за</nobr>&nbsp;туч.

The default export of richtypo-rules-ru contains recommended rules (marked with ¹ in a table below), but you can import each rule separately:

import richtypo from 'richtypo';
import { quotes, numberSeparators } from 'richtypo-rules-ru';
richtypo(
  [quotes, numberSeparators],
  'Текст "в кавычках" - 123456,78'
);
// -> Текст «в кавычках» - 123&#x202f;456,78

See more examples in Richtypo docs.

The rules

Rule Description Input Output
abbrs¹ wrap abbreviations in <abbr> tag БКОАНТОЛО <abbr>БКОАНТОЛО</abbr>
dashes¹ transform a dash between two words to an em dash (—), add a non-breaking space before an em dash собака - друг собака&nbsp;— друг²
degreeSigns¹ add a non-breaking space between a number and a degree sign (°) 13 °C 13&#x202f;°C
ellipses¹ transform three dots (...) to an ellipsis (…) ...
etcs¹ add a non-breaking space inside “и т. д.” and “и т. п.” и т. д. и&nbsp;т.&nbsp;д.²
hyphenatedWords¹ wrap words with a hyphen in <nobr> tag из-за <nobr>из-за</nobr>
initials¹ wrap initials in <nobr> tag В. И. Ленин <nobr>В. И. Ленин</nobr>
numberSigns¹ add a non-breaking space between a number sign (№) and a number № 3 №&nbsp;3²
numberUnits¹ add a non-breaking space between a number and its unit 2 кг 2&nbsp;кг²
orphans¹ add a non-breaking space in front of the last word in a paragraph (line) собака лучший друг собака лучший&nbsp;друг²
particles¹ add a non-breaking space before particles это ж как бы это&nbsp;ж как&nbsp;бы²
quotes¹ transform dumb quotes (") to typography quotes («») текст "в кавычках" текст «в кавычках»
sectionSigns¹ add a non-breaking space between a section sign (§) and a number § 3 §&nbsp;3²
shortWords¹ add a non-breaking space after short words в печали в&nbsp;печали²

¹ Recommended rules (see code examples above)

² &nbsp; is actually rendered as a symbol (\xA0), not an HTML entity. We use &nbsp; only in the docs for readability.

Package Sidebar

Install

npm i richtypo-rules-ru

Weekly Downloads

74

Version

5.1.3

License

MIT

Unpacked Size

9.23 kB

Total Files

5

Last publish

Collaborators

  • sapegin