wcactus/typographru
Composer 安装命令:
composer require wcactus/typographru
包简介
Laravel 5 screen typography module for russian language
README 文档
README
Usage / Demonstration
For unicode text:
$input = 'Falcon Heavy (букв. с англ. "Тяжёлый "Сокол"") - американская ракета-носитель (РН) сверхтяжёлого класса с возможностью повторного использования 1-й ступени , спроектированная и произведённая-таки компанией SpaceX...'; echo TypographRu::typograph($input); /* output (with nonbreaking spaces, nonbreaking dashes and other special unicode symbols): Falcon Heavy (букв. с англ. «Тяжёлый „Сокол“») – американская ракета-носитель (РН) сверхтяжёлого класса с возможностью повторного использования 1‑й ступени, спроектированная и произведённая‑таки компанией SpaceX… */
The screen typography is best viewed here for win-1251-encoded text:
$input = 'Falcon Heavy (букв. с англ. "Тяжёлый "Сокол"") - американская ракета-носитель (РН) сверхтяжёлого класса с возможностью повторного использования 1-й ступени , спроектированная и произведённая-таки компанией SpaceX...'; echo TypographRu::typograph($input); /* output: Falcon Heavy (букв. с англ. «Тяжёлый „Сокол“») – американская ракета-носитель (РН) сверхтяжёлого класса с возможностью повторного использования <nobr>1-й</nobr> ступени, спроектированная и <nobr>произведённая-таки</nobr> компанией SpaceX… */
Installation
Add TypographRu to your Laravel project: composer require wcactus/typographru
Facade and service provider will be autoloaded.
The middle-length dash (the same as – HTML entity) is used by default. If you prefer the longest dash (the same as — HTML entity), you need to publish configuration file info config/typographru.php using php artisan vendor:publish --tag=typographru command and then set use_mdash configuration property to true.
Methods
TypographRu::typograph(string $text, [string $language = null, [boolean $forceQuotes = true]])
Applies screen typography to unicode string. It is assumed that all special characters in the source string are represented by unicode characters, rather than HTML entities. If some HTML entities are used as special characters, they will be converted to unicode characters (except of non-typography-specific entities). All changes in the returned string are performed using unicode characters.
string $text: text to typograph.
string $language: Optional. Can be TypographRu::LANGUAGE_RU, TypographRu::LANGUAGE_EN or null (i.e. auto-detect russian language). Affects only the kind of quotation marks, the screen typography does not fully applied to the english language. May be useful in multilanguage websites.
boolean $forceQuotes: Optional. If true, the previously placed «correct» quotes will be re-placed again.
TypographRu::typographWin1251(string $text, [string $language = null, [boolean $forceQuotes = true]])
Applies screen typography to win-1251-encoded string. It is assumed that all special characters in the source string are represented by HTML entities due to the limitations of Win-1251 encoding. All changes in the returned string are performed using HTML entities.
string $text: text to typograph.
string $language: Optional. Can be TypographRu::LANGUAGE_RU, TypographRu::LANGUAGE_EN or null (i.e. auto-detect russian language). Affects only the kind of quotation marks, the screen typography does not fully applied to the english language. May be useful in multilanguage websites.
boolean $forceQuotes: Optional. If true, the previously placed «correct» quotes will be re-placed again.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-24