@puwenhui/dsh-md2pdf 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 +14 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,23 +24,25 @@ dsh plugin --profile web add @puwenhui/dsh-md2pdf
|
|
|
24
24
|
也可以从本地目录安装(开发中/未发布时):
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
|
-
dsh plugin --profile web add file
|
|
27
|
+
dsh plugin --profile web add file:<本地插件目录的绝对路径>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
包内声明了 `dsh.bundle.patch`,`dsh` 会**自动**把本包追加进 profile 的 `dsh.profile.bundles`,无需手改任何 profile 清单。
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
安装后**重启宿主**(bundle 层只在启动时组装):
|
|
33
33
|
|
|
34
|
-
```
|
|
35
|
-
|
|
34
|
+
```sh
|
|
35
|
+
dsh web
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
验证是否挂上(不必启动服务):
|
|
39
39
|
|
|
40
|
-
```
|
|
41
|
-
|
|
40
|
+
```sh
|
|
41
|
+
dsh --profile web --dump-config | grep md2pdf
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
> 若 `dsh` 未加入 PATH,用 `node <DSH 安装目录>/apps/cli/lib/bin.js` 代替上面的 `dsh` 即可。
|
|
45
|
+
|
|
44
46
|
### ⚠️ 安装时实测到的坑:`dsh plugin add` 会剪掉 profile 的安装回退链接
|
|
45
47
|
|
|
46
48
|
本插件是在**真实 web profile** 上实测安装的,过程中踩到一个 DSH 层面的坑,记录在此以免重踩:
|
|
@@ -53,8 +55,8 @@ dsh plugin --profile web add file:D:/ds-harness/dsh-md2pdf-plugin
|
|
|
53
55
|
**判断方法**:把 composed config 里每个插件行的 `name` 逐个从 profile 目录解析一遍,
|
|
54
56
|
只要有一个解析不到,宿主就一定起不来:
|
|
55
57
|
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
+
```sh
|
|
59
|
+
dsh --profile web --dump-config # 取全部 name
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
**修复**:把缺失的内置包补回 `$DSH_HOME/profiles/node_modules/@deepseek-ai/`
|
|
@@ -72,7 +74,7 @@ dsh plugin --profile web add file:D:/ds-harness/dsh-md2pdf-plugin
|
|
|
72
74
|
| `@deepseek-ai/dsh-client-ui-chat` | `packages/client/ui-chat` |
|
|
73
75
|
| `@deepseek-ai/dsh-client-ui-schedule` | `packages/client/ui-schedule` |
|
|
74
76
|
|
|
75
|
-
(`packages/` 指
|
|
77
|
+
(`packages/` 指 DSH 安装目录或源码检出目录下的 `packages/` 子目录。)
|
|
76
78
|
|
|
77
79
|
> 该问题与插件内容无关:任何 `dsh plugin add` 都可能触发。若 `dsh plugin add` 被中断
|
|
78
80
|
> (例如网络卡在某个 optional 包的拉取上而超时),更容易留下这种半成品状态。
|
|
@@ -81,7 +83,7 @@ dsh plugin --profile web add file:D:/ds-harness/dsh-md2pdf-plugin
|
|
|
81
83
|
|
|
82
84
|
对话里直接说,例如:
|
|
83
85
|
|
|
84
|
-
- 「把
|
|
86
|
+
- 「把 `手册.md` 转成 PDF」(相对路径按会话工作目录解析)
|
|
85
87
|
- 「把 `docs/` 目录下所有 md 都转成 PDF」
|
|
86
88
|
- 「转这个 md,页眉写『某某手册』」
|
|
87
89
|
|
|
@@ -127,7 +129,7 @@ dsh plugin --profile web add file:D:/ds-harness/dsh-md2pdf-plugin
|
|
|
127
129
|
## 自检
|
|
128
130
|
|
|
129
131
|
```sh
|
|
130
|
-
cd
|
|
132
|
+
cd dsh-md2pdf-plugin # 源码检出目录
|
|
131
133
|
node scripts/smoke.mjs # 29 项断言:模块契约→工具注册→真渲染→下载端点→DSH schema 校验
|
|
132
134
|
node scripts/convert.mjs <a.md> [--out <dir>] [--title <t>] [--label <l>] # 命令行直转(等价原 md2pdf.mjs)
|
|
133
135
|
```
|
|
@@ -139,7 +141,7 @@ smoke 用假 `ctx` 把整条链路跑一遍,退出码即结果;convert 是
|
|
|
139
141
|
渲染管线、页眉页脚版式、A4 页边距、`guide-style.css` 全部保持一致,产物外观相同。移植过程中**修掉了原脚本的两个真实缺陷**:
|
|
140
142
|
|
|
141
143
|
1. **标题渲染成了 `<hh1>`**:原 `heading_open` 规则写 `` `<h${tokens[idx].tag} ...>` ``,而 markdown-it 的 `token.tag` 已经是 `h1`,于是产出 `<hh1>`——未知元素会退化成 `inline`,**所有标题的一级/二级样式全部丢失**(实测原稿 h1 与正文同字号)。现改为 `<${tokens[idx].tag} ...>`,标题按 CSS 正常缩放(h1 = 1.9em)。
|
|
142
|
-
2. **带 UTF-8 BOM 的 .md 取不到页眉标题**:BOM 让首行 `#` 前多一个 `\uFEFF`,`^#` 匹配失败,页眉退化成文件名。现读取时统一去 BOM,并把正则放宽到允许 ATX 标题前最多 3
|
|
144
|
+
2. **带 UTF-8 BOM 的 .md 取不到页眉标题**:BOM 让首行 `#` 前多一个 `\uFEFF`,`^#` 匹配失败,页眉退化成文件名。现读取时统一去 BOM,并把正则放宽到允许 ATX 标题前最多 3 个空格。实测原项目的《SDK 接入手册》正是带 BOM 的文件,所以该 bug 在原脚本下是必然触发的。
|
|
143
145
|
|
|
144
146
|
两项均已在 `scripts/smoke.mjs` 里加了回归断言。
|
|
145
147
|
|