梦游者/排版

在网页发布前准备俄语文本。

1.4.0 2017-02-01 16:09 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:17:50 UTC


README

#Typographie.php Build Status Dependency Status

准备俄语文本以供网页发布的库。
Typographie 网络服务的核心。

安装

将包添加到 composer.json

composer require asleepwalker/typographie

运行 Composer

composer install

示例

<?php

use asleepwalker\typographie\Typographie;

$engine = new Typographie('quotes,inquot,dashes,specials,paragraphs');

$raw = 'Сервис "Typographie" - подготовка текстов к веб-публикации онлайн (с) 2014-2017';
echo $engine->process($raw);
// > Сервис «Typographie» — подготовка текстов к веб-публикации онлайн © 2014–2017

操作

quotes : 校正引号:"" 变为 «»。
inquot (需要 quotes) : 嵌套引号:«„“» (否则 — 重复引号堆叠)。
dashes : 如有必要,将连字符替换为破折号和减号。
angles : 将星号和引号替换为度、英尺、英寸。
dblspace : 修复文本中的重复空格。
specials : 插入特殊字符(来自符号表)。
mathchars : 插入数学符号(来自同一表)。
punctuation : 修复标点,例如逗号前的空格。
specialspaces : 修复与空格一起跳过的错误特殊字符。
nbsp : 将短词附加到文本中的后续词。
hellip : 将重复的点符号替换为省略号。
paragraphs : 在转换为 HTML 时插入段落(<p>)(以空字符串作为分隔符)。
safehtml : 不要处理 <code> 和 <pre> 块内的文本。
entities : 将特殊字符替换为 HTML 实体。

列表应以逗号分隔,例如 action1,action2,action3

除了在对象构造函数中定义之外,还可以通过方法 actions 更改配置

$engine->actions('punctuation,dblspace');
echo $engine->process('К  чёрту орфографию ,главное   все понимают !Ведь так  ?..');
// > К чёрту орфографию, главное все понимают! Ведь так?..

模式

plain : 只是纯文本。
html : 安全 HTML 处理。

模式可以在构造函数中定义

$engine = new Typographie('quotes,dashes', $in, $out);

或通过方法 mode 定义

$engine->mode('html', 'plain');

默认配置是输入和输出的 plain 模式。

许可证

MIT 许可证。