fater/typography
Composer 安装命令:
composer require fater/typography
包简介
Simple way to make your text more typographer
README 文档
README
"Typography" is an open source PHP software that automatically can format your text. It can place spaces and correct mechanical errors in the text, replace characters and brackets. This software can be useful for people who are engaged in the production and formatting of texts for public purposes, such as web pages, promotional materials, presentations, resumes, news, public posts, etc.
Using the "Typography" allows you to significantly reduce the time for correcting and formatting the text, since the service automatically processes all the necessary actions. In addition, "Typography" guarantees high accuracy and quality of correction, which helps to avoid punctuation errors.
This can be especially useful for professional writers, journalists, advertisers and other people whose work is related to text content.
Table Of Contents
Requirements
- PHP 8.0 or higher
Installation
Install with composer:
composer require fater/typography
Usage Examples
To run "Typography" with default formatting rules use this code example:
<?php use Fater\Typography\Typography; $formattedText = Typography::init()->apply('Your text'); echo $formattedText;
Create your own formatting rule
If you want to make special formatting rules you can make class from base rule template:
<?php use Fater\Typography\Rules\Rule; use Your\Namespace\Rules; class YourOwnRule extends Rule { public function handle(string $text): string { // Your code modification rules $text .= ' World!'; // Return formatted text return $text; } }
Add your rule to default formatting rules
Add your rule to the list of handlers to use it:
<?php use Fater\Typography\Typography; use Fater\Typography\TypographyRules; use Your\Namespace\Rules\YourOwnRule; $rules = TypographyRules::init()->addRules([YourOwnRule::class]); // Text will be formatted with default list of rules including your rule $formattedText = Typography::init($rules) // Set rules instance with your rule ->apply('Hello');
if you want to use only your rule
At the beginning clear all rules list, add your rule to the list of handlers to use it:
<?php use Fater\Typography\Typography; use Fater\Typography\TypographyRules; $rules = TypographyRules::init() ->clearAll() ->addRules([YourOwnRule::class]); // Text will be formatted only with your rule $formattedText = Typography::init($rules) // Set rules instance with your rule ->apply('Hello'); echo $formattedText;
The above example will output:
Hello World!
Roadmap
v. 1.x
- Space:
- Add space after comma
- Add space after dot (ignore domains) TODO: emails/IP
- Remove space before punctuation (.,:;?!)
- Remove space in each paragraph
- Remove redundant line breaks
- Characters:
- Replace special characters (c), (r), (tm), +-, ..., <-, ->
- Replace dash
- First letter in uppercase
v. 2.x
Supports of formatting plain text and HTML code
Changelog
Read Changelog in releases list to know all product changes.
License
License MIT, see more details in LICENSE
fater/typography 适用场景与选型建议
fater/typography 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fater/typography 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fater/typography 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-08