@deepwhale-cn/dsh-cn-doc-formatter 0.1.0 → 0.1.1
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/README.md +1 -1
- package/lib/index.js +3 -3
- package/package.json +18 -2
- package/skill/chinese-doc-formatter.md +1 -1
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ pip install python-docx reportlab fontTools pypdf
|
|
|
113
113
|
**3. 跨平台字体探测**
|
|
114
114
|
|
|
115
115
|
早期实现用 `fc-list` 探测字体,而 **macOS 不预装 fontconfig**,
|
|
116
|
-
|
|
116
|
+
异常被吞掉后恒返回「字体不存在」,于是**即使装了仿宋也检测不到**,会始终走回退分支。
|
|
117
117
|
本版改为直接读字体文件的 `name` 表,macOS / Windows / Linux 通用。
|
|
118
118
|
|
|
119
119
|
## 用法
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 其授权允许在文档中使用,但不允许再分发字体文件本身。因此这里是「排版引擎」,
|
|
10
10
|
* 字体由用户自备,通过环境变量或系统字体目录提供:
|
|
11
11
|
*
|
|
12
|
-
* DSH_CN_FANGSONG
|
|
12
|
+
* DSH_CN_FANGSONG 仿宋常规体文件的完整路径(最高优先)
|
|
13
13
|
* DSH_CN_FANGSONG_BOLD 仿宋加粗体(可选)
|
|
14
14
|
* DSH_CN_FONT_DIR 一个目录,脚本在其中按文件名查找
|
|
15
15
|
*
|
|
@@ -34,7 +34,7 @@ const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
34
34
|
/** 随包分发的 skill 与脚本所在目录 */
|
|
35
35
|
const skillDir = join(packageRoot, 'skill');
|
|
36
36
|
|
|
37
|
-
/** 技能正文里用来占位脚本目录的标记 ——
|
|
37
|
+
/** 技能正文里用来占位脚本目录的标记 —— 运行期替换成真实完整路径 */
|
|
38
38
|
const SKILL_DIR_PLACEHOLDER = '<skill目录>';
|
|
39
39
|
|
|
40
40
|
export const name = 'cn-doc-formatter';
|
|
@@ -43,7 +43,7 @@ export const inject = ['skills'];
|
|
|
43
43
|
/** 技能标识:kebab-case。刻意避开 'chinese-doc-formatter',见文件头说明 */
|
|
44
44
|
const SKILL_NAME = 'cn-doc-formatter';
|
|
45
45
|
|
|
46
|
-
/** 随包分发的 skill
|
|
46
|
+
/** 随包分发的 skill 目录完整路径(安装后位置由加载器决定) */
|
|
47
47
|
export function skillDirPath() {
|
|
48
48
|
return skillDir;
|
|
49
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepwhale-cn/dsh-cn-doc-formatter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "中文公文排版:按 GB/T 9704-2012 生成 .docx / .pdf / .txt,附输出自检。不含字体文件,字体由用户自备。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,14 @@
|
|
|
14
14
|
"公文",
|
|
15
15
|
"排版",
|
|
16
16
|
"仿宋",
|
|
17
|
-
"GB/T 9704"
|
|
17
|
+
"GB/T 9704",
|
|
18
|
+
"chinese",
|
|
19
|
+
"document",
|
|
20
|
+
"formatting",
|
|
21
|
+
"government-document",
|
|
22
|
+
"gbt9704",
|
|
23
|
+
"typesetting",
|
|
24
|
+
"official-document"
|
|
18
25
|
],
|
|
19
26
|
"files": [
|
|
20
27
|
"lib",
|
|
@@ -38,5 +45,14 @@
|
|
|
38
45
|
},
|
|
39
46
|
"peerDependencies": {
|
|
40
47
|
"@deepseek-ai/dsh-skill": "*"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/feely0208/dsh-cn-skills.git",
|
|
52
|
+
"directory": "dsh-cn-doc-formatter"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/feely0208/dsh-cn-skills#readme",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/feely0208/dsh-cn-skills/issues"
|
|
41
57
|
}
|
|
42
58
|
}
|
|
@@ -291,7 +291,7 @@ return bool(out.stdout.strip())
|
|
|
291
291
|
```
|
|
292
292
|
|
|
293
293
|
`fc-list` 是 fontconfig 的命令,**macOS 不预装**。异常被 `except` 吞掉后函数恒返回
|
|
294
|
-
`False`,于是**即使机器上装了 `仿宋_GB2312`
|
|
294
|
+
`False`,于是**即使机器上装了 `仿宋_GB2312` 也检测不到**,会始终走回退分支。
|
|
295
295
|
|
|
296
296
|
→ 已改为直接扫描字体文件读 `name` 表(fontTools),macOS / Windows / Linux 通用,
|
|
297
297
|
并逐个候选名实测,避免再把字体名写错。
|