rockett / textformatter-typographer
Typographer 是一个用于 PHP Typography 包的 ProcessWire 包装器。
2.0.0
2023-07-01 09:16 UTC
Requires
- php: >=7.4.0
- composer/installers: ^2.2
- mundschenk-at/php-typography: ^6.7
README
Typographer 是一个用于 PHP Typography 类的 ProcessWire 包装器,最初由 KINGdesk LLC 撰写,并由 Peter Putzer 为 wp-Typography 进行了增强。类似于 Smartypants,它通过增强的排版和排版功能增强了文本字段,例如智能引号、59 种语言的连字符、省略号、版权、商标和服务标记、数学符号等。
安装
可以通过在模块目录中搜索 TextformatterTypographer 来安装此模块。
或者,您可以使用 Composer
composer require rockett/textformatter-typographer
用法
要使用 Typographer,只需像通常一样在字段上应用文本格式化即可。
如果您正在与不属于正常 ProcessWire 页面系统的内容交互,例如从外部源获取内容,您可以使用模块类上的 formatString
方法。
print $modules ->get('TextformatterTypographer') ->formatString('"Hello, world!"');
配置
此模块是可配置的。请随意访问配置页面,了解可以切换和配置的内容。
要程序化地修改 Typographer 设置类的实例,请挂钩到 customTypographerSettings
方法。
wire()->addHookAfter('TextformatterTypographer::customTypographerSettings', function (HookEvent $event) { /** @var \PHP_Typography\Settings $settings */ $settings = $event->return; $lang = $event->user->language->name; // Set configurations based on language, for example: if ($lang === 'de') { $settings->set_hyphenation_language('de'); $settings->set_smart_quotes_primary('doubleLow9Reversed'); $settings->set_smart_quotes_secondary('singleLow9Reversed'); } });
许可证
此项目采用宽松的 MIT 许可证,它依赖的库有自己的许可证。请查阅许可证文件。