denshoch/harusame 问题修复 & 功能扩展

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

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

denshoch/harusame

Composer 安装命令:

composer require denshoch/harusame

包简介

Add special HTML classes for Tate-Chu-Yoko and text-orientaion.

README 文档

README

Harusame is a library designed to control the orientation of characters in vertical writing. It allows for the proper display of text in Japanese vertical format, ensuring that characters are displayed upright or sideways as needed. This is particularly useful for applications that require text to be formatted according to traditional Japanese typesetting standards.

Wrap sequence of numbers (default is two-digit) and sequence of EXCLAMATION (QUESTION) MARKs with span.tcy in (see Tate-Chu-Yoko).

Wrap each character of upright glyph orientation with span.upright and sideways glyph orientation with span.sideways (see UTR50).

Expected CSS;

.tcy {
    text-combine-upright: all;
}
.upright {
    text-orientation: upright;
}
.sideways {
    text-orientation: sideways;
}

Install

composer install

Usage

New static method transformText

$result = Denshoch\Harusame::transformText('平成20年!?');
// => 平成<span class="tcy">20</span>年<span class="tcy">!?</span>

// With options
$options = ['tcyDigit' => 3];
$result = Denshoch\Harusame::transformText('10円玉と100円玉がある。', $options);
// => <span class="tcy">10</span>円玉と<span class="tcy">100</span>円玉がある。

Previous usage

$harusame = new Denshoch\Harusame();
$harusame->transform('平成20年!?');
// => 平成<span class="tcy">20</span>年<span class="tcy">!?</span>

$harusame->transform('<html><head><title>平成20年!?</title></head><body>平成20年!?</body></html>');
// You can pass HTML string. Only text nodes within the body tag are transformed.
// => <html><head><title>平成20年!?</title></head><body>平成<span class="tcy">20</span>年<span class="tcy">!?</span></body></html>

$harusame->transform('⓵☂÷∴');
// => <span class="upright">⓵</span><span class="upright">☂</span><span class="sideways">÷</span><span class="sideways">∴</span>

Options

$options = array("tcyDigit" => 3);
$harusame = new Denshoch\Harusame($options);
$harusame->transform('10円玉と100円玉がある。');
// => <span class="tcy">10</span>円玉と<span class="tcy">100</span>円玉がある。
// or
$harusame = new Denshoch\Harusame();
$harusame->tcyDigit = 3;
$harusame->transform('10円玉と100円玉がある。');
// => <span class="tcy">10</span>円玉と<span class="tcy">100</span>円玉がある。
Key Type Initial Description
tcyDigit integer 2 Maximum number of digits to add .tcy class. If set to 0, no .tcy class will be added.
autoTextOrientation boolean true Add .upright and .sideways class or not.

Error Handling

When invalid XML is provided as input, the transform method will return the original text instead of throwing an exception. Additionally, an error message will be logged to indicate that invalid XML was encountered. This allows for graceful handling of errors while still providing feedback about the issue.

Test

$ vendor/bin/phpunit

denshoch/harusame 适用场景与选型建议

denshoch/harusame 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 849 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 denshoch/harusame 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-20