GithubHelp home page GithubHelp logo

khizrim / typo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nufeen/typo

0.0 0.0 0.0 866 KB

Russian typography and hyphenation script

License: Do What The F*ck You Want To Public License

JavaScript 5.65% TypeScript 94.35%

typo's Introduction

Типограф (Russian typography script)

Documentation below will remain in russian since this package is language-specific and seems to be needed by russian-speaking users only.

Cкрипт для расстановки переносов и привязывания предлогов в русскоязычных текстах.

Installation

npm install ru-typo

Usage

По умолчанию привязываются предлоги, тире заменяется на широкое:

typo(string)
Before After
не в силах выдержать несовершенства мира - закрыл я очи невсилах выдержать несовершенства мира— закрыл я очи

Options

digits

При достаточно широкой колонке цифры привязываются с двух сторон:

typo(string, { digits: true })
Before After
...купите 200 граммов водки и 30 граммов огурца ...купите200граммов водки и30граммов огурца

digitsR

Привязывает цифры слева:

typo(string, { digitsR: true })
Before After
...купите 200 граммов водки и 30 граммов огурца ...купите 200граммов водки и 30граммов огурца

header

В заголовках приклеиваются длинные предлоги:

typo(string, { header: true })
Before After
Как ничего не понять и не подать виду Какничего непонять инеподать виду

hyphen

Обратите внимание, в части браузеров на сегодня уже работают нативные css переносы (с указанным в html языком): https://developer.mozilla.org/ru/docs/Web/CSS/hyphens#Browser_compatibility

расстановка переносов:

typo(string, { hyphens: true })
Before After
В это время Ленин скрывается на конспиративной квартире. В это вре­мя Ле­нин скры­ва­ет­ся на кон­спи­ратив­ной квар­ти­ре.

Регулярные выражения для переносов взяты с http://vyachet.ru/hyphen-russian-html-text/ (модифицированный алгоритм Христова).

quotes

Превращает "прямые кавычки" в «ёлочки»:

typo(string, { quotes: true })
Before After
Обратиться в ООО "Компания "Рога и Ко." Обратиться вООО «Компания «Рога иКо.»

typo's People

Contributors

nufeen avatar ignatvilesov avatar vpukhanov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.