nystudio107/php-typography 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nystudio107/php-typography

Composer 安装命令:

composer require nystudio107/php-typography

包简介

The KINGdesk PHP Typography library improves typography on the web.

README 文档

README

PhpTypography is based on the PHP Typography library by KINGdesk. It is extended to support the PSR-0 autoloading standard.

Installation

Install PhpTypography with composer via

composer require debach/php-typography:dev-master
composer install

and then use the class like

$html       = '...';
$typography = new Debach\PhpTypography\PhpTypography();
$prettyHtml = $typography->process($html);

What PhpTypography does

PhpTypography enhances the typography of the text on your web pages. The following table shows some examples of HTML texts before and after processing.

Before After Explanation
explanation ex­pla­na­tion Robust hyphenation with soft hyphens ­. The browser will hyphenate words automatically based on the current line width. This is especially useful where the line width is rather small, for example in multi-column texts (CSS property column-count).
I'm waiting for "Peter" I’m waiting for “Peter” Use correct quotes and apostrophes
... Use the ellipses symbol
A flock of sparrows - some of them juveniles - alighted and sang. A flock of sparrows — some of them juveniles — alighted and sang. Use an em-dash instead of a hypen
14-20 men 14–20 men Use an en-dash instead of a hypen in ranges
Acme Corporation & Partners Acme Corporation <span class="amp">&</span> Partners Ampersands symbols are marked up so that you can choose a different font for them and make them look beatiful. Search the web for “ampersand font” as a start.

For more examples, see the project homepage.

How to use PhpTypography

Construct an instance $typography of Debach\PhpTypography\PhpTypography and call $typography->process($html) on it with the HTML text $html you want to process:

$html       = '<p>I\'m waiting for "Peter"...</p>';
$typography = new Debach\PhpTypography\PhpTypography();
$prettyHtml = $typography->process($html);
echo $prettyHtml;

The above code will print (soft hyphens not shown)

<p>I’m waiting for “Peter”…</p>

By the way, if you’re using the full-stack Symfony framework and Twig, there is also the TypographyBundle which comes with nice little helpers such as the {% typography %} tag and the {{ text|typography }} filter.

Configuration

A thorough explanation of the configuration can be found at the KINGdesk homepage.

Hyphenation depends on the language, which can be set with set_hyphenation_language($languageCode). For example, to set the hyphenation language to French or German, call

$typography->set_hyphenation_language('fr'); // set to French
$typography->set_hyphenation_language('de'); // set to German

The default language is American English. Refer to the filenames in the lang/ directory for an overview of available languages.

nystudio107/php-typography 适用场景与选型建议

nystudio107/php-typography 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nystudio107/php-typography 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nystudio107/php-typography 我们能提供哪些服务?
定制开发 / 二次开发

基于 nystudio107/php-typography 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-10-15