@sw7d/paper-renderer 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paper-renderer.js +1241 -1219
- package/dist/src/utils/textWrap.d.ts +3 -1
- package/dist/src/utils/wrapRules.d.ts +8 -1
- package/package.json +1 -1
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* 1. 原子化:数字串/英文单词/选项标签/成对标点(——、……)整体不可拆;
|
|
14
14
|
* 2. 行首禁则 + 行尾禁则(避头尾);
|
|
15
15
|
* 3. 避头尾处理优先级:标点挤压 → 标点悬挂 → 整字回退;
|
|
16
|
-
* 4.
|
|
16
|
+
* 4. 两端对齐:非末行按剩余空间均匀拉开字距(限制最大字距,避免稀字);
|
|
17
|
+
* 5. 对称直引号(" '):由 wrapRules.applyAmbiguousQuoteRules 按前一个字符判定开闭,
|
|
18
|
+
* 闭引号禁行首、开引号禁行末(全角 “ ” 已在字符集里)。
|
|
17
19
|
*/
|
|
18
20
|
import type { InlineElement, Line, WrapRules } from '../types/paper';
|
|
19
21
|
/**
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* 2. 原子(Atom)是折行的最小单位:数字串、英文单词、选项标签、成对标点(——、……)
|
|
11
11
|
* 各自为一个原子,永不在内部断行;
|
|
12
12
|
* 3. 原子化在这里完成,因此无论调用方传进来的是「单字符元素」(编辑器 reflow)
|
|
13
|
-
* 还是「整段文本元素」(HTML 导入 /
|
|
13
|
+
* 还是「整段文本元素」(HTML 导入 / 文档反序列化),折行结果都一致;
|
|
14
|
+
* 4. 对称直引号(" ')没有开闭字形,不能静态归入禁则表,改由 applyAmbiguousQuoteRules
|
|
15
|
+
* 按前一个字符判定:闭引号禁行首、开引号禁行末(全角弯引号 “ ” 仍走字符集)。
|
|
14
16
|
*/
|
|
15
17
|
import type { InlineElement, TextInline, UnderlineInline, WrapRules } from '../types/paper';
|
|
16
18
|
export declare function isNoStartChar(ch: string | undefined): boolean;
|
|
@@ -56,6 +58,11 @@ export declare function scanTokens(text: string): Array<{
|
|
|
56
58
|
from: number;
|
|
57
59
|
to: number;
|
|
58
60
|
}>;
|
|
61
|
+
/**
|
|
62
|
+
* 给对称引号补上避头尾属性:闭引号禁行首(noStart),开引号禁行末(noEnd)。
|
|
63
|
+
* 必须在原子合并之后调用——合并后前一个原子才是完整的词/句,判定才准确。
|
|
64
|
+
*/
|
|
65
|
+
export declare function applyAmbiguousQuoteRules(atoms: Atom[]): Atom[];
|
|
59
66
|
/**
|
|
60
67
|
* 将内联元素展开为断行原子。
|
|
61
68
|
* 不修改入参数组,text 元素一律浅拷贝,调用方可安全复用原数据。
|