@v1hz/md2docx 2.1.1 → 2.2.0

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 CHANGED
@@ -26,6 +26,7 @@
26
26
  | Mermaid 图表 | 使用 beautiful-mermaid 和 resvg-wasm 将 Mermaid 渲染为高 DPI PNG |
27
27
  | Word 样式 | 根据 JSON 样式生成 Pandoc reference DOCX,也可从现有 DOCX 提取样式 |
28
28
  | Markdown 格式化 | 可只运行预处理流水线,输出格式化后的 Markdown |
29
+ | 去除分隔符 | 默认移除 `---`、`***`、`___` 等分隔符行,减少无用页面间距 |
29
30
  | 集中缓存 | 中间文件统一存储到 `~/.md2docx/`,不会在当前目录创建 `tmp/` |
30
31
  | Node 与可执行版本 | 支持 npm CLI,也支持构建不依赖 Node.js/Bun 的 Windows 可执行文件 |
31
32
 
@@ -208,6 +209,7 @@ CLI 不支持覆盖单个配置项,所有配置都通过 JSON 文件管理。
208
209
  | `renderMermaid.enabled` | 将 Mermaid 渲染为 PNG | `true` |
209
210
  | `renderMermaid.theme` | beautiful-mermaid 主题 | `"tokyo-night-light"` |
210
211
  | `renderMermaid.density` | PNG 输出 DPI,最小值 72 | `200` |
212
+ | `removeThematicBreaks.enabled` | 移除 `---`、`***`、`___` 等分隔符行 | `true` |
211
213
 
212
214
  ## 样式定制
213
215
 
@@ -268,6 +270,8 @@ Markdown
268
270
 
269
271
  addTitle()
270
272
 
273
+ removeThematicBreaks()
274
+
271
275
  normalizeHeadings()
272
276
 
273
277
  numberHeadings()
@@ -287,6 +291,7 @@ Pandoc + Lua filter
287
291
  DOCX
288
292
  ```
289
293
 
294
+ `removeThematicBreaks()` 在标题处理之前执行,避免分隔符干扰文档结构。
290
295
  `numberTables()` 必须先于 Mermaid 渲染;`numberPictures()` 必须后于 Mermaid 渲染,这样 Mermaid 生成的图片也能获得图题。
291
296
 
292
297
  ## 构建
@@ -26,5 +26,8 @@
26
26
  "detectTitle": {
27
27
  "enabled": true,
28
28
  "strategy": "first-h1"
29
+ },
30
+ "removeThematicBreaks": {
31
+ "enabled": true
29
32
  }
30
33
  }
@@ -141,6 +141,19 @@
141
141
  }
142
142
  },
143
143
  "required": ["enabled", "strategy"]
144
+ },
145
+ "removeThematicBreaks": {
146
+ "description": "分隔符",
147
+ "type": "object",
148
+ "additionalProperties": false,
149
+ "properties": {
150
+ "enabled": {
151
+ "description": "自动移除 markdown 中的分隔符(---, ***, ___)",
152
+ "type": "boolean",
153
+ "default": true
154
+ }
155
+ },
156
+ "required": ["enabled"]
144
157
  }
145
158
  },
146
159
  "required": [
@@ -149,6 +162,7 @@
149
162
  "normalizeHeadings",
150
163
  "numberHeadings",
151
164
  "renderMermaid",
152
- "detectTitle"
165
+ "detectTitle",
166
+ "removeThematicBreaks"
153
167
  ]
154
168
  }
package/dist/index.js CHANGED
@@ -128401,7 +128401,7 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
128401
128401
  // package.json
128402
128402
  var package_default = {
128403
128403
  name: "@v1hz/md2docx",
128404
- version: "2.1.1",
128404
+ version: "2.2.0",
128405
128405
  description: "基于 pandoc 的 Markdown 转 Word 工具,自动格式化 Markdown,支持自定义样式,AI 友好,用户友好。",
128406
128406
  keywords: [
128407
128407
  "converter",
@@ -128595,6 +128595,7 @@ function validateConfig(value, path2) {
128595
128595
  if (!Number.isInteger(mermaid.density) || mermaid.density < 72) {
128596
128596
  invalidConfig(path2, "renderMermaid.density", "必须是不小于 72 的整数");
128597
128597
  }
128598
+ validateEnabled(root.removeThematicBreaks, path2, "removeThematicBreaks");
128598
128599
  const title = expectRecord(root.detectTitle, path2, "detectTitle");
128599
128600
  expectBoolean(title.enabled, path2, "detectTitle.enabled");
128600
128601
  const strategy = expectString(title.strategy, path2, "detectTitle.strategy");
@@ -146041,6 +146042,11 @@ function expandHexColor(color2) {
146041
146042
  return color2.length === 4 ? `#${color2[1]}${color2[1]}${color2[2]}${color2[2]}${color2[3]}${color2[3]}` : color2;
146042
146043
  }
146043
146044
 
146045
+ // src/preprocess/thematic-break.ts
146046
+ function removeThematicBreaks(root2) {
146047
+ root2.children = root2.children.filter((node2) => node2.type !== "thematicBreak");
146048
+ }
146049
+
146044
146050
  // src/preprocess/index.ts
146045
146051
  async function preprocess2(mdPath, cfg, outDir, assetUrlDir = outDir) {
146046
146052
  const md = await readFile3(mdPath, "utf-8");
@@ -146051,6 +146057,9 @@ async function preprocess2(mdPath, cfg, outDir, assetUrlDir = outDir) {
146051
146057
  headings.push(heading2);
146052
146058
  });
146053
146059
  addTitle(mdPath, ast, headings, cfg.detectTitle);
146060
+ if (cfg.removeThematicBreaks.enabled) {
146061
+ removeThematicBreaks(ast);
146062
+ }
146054
146063
  if (cfg.normalizeHeadings.enabled || cfg.numberHeadings.enabled) {
146055
146064
  normalizeHeadings(headings);
146056
146065
  }
@@ -146102,6 +146111,9 @@ var config_default = `{
146102
146111
  "detectTitle": {
146103
146112
  "enabled": true,
146104
146113
  "strategy": "first-h1"
146114
+ },
146115
+ "removeThematicBreaks": {
146116
+ "enabled": true
146105
146117
  }
146106
146118
  }
146107
146119
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v1hz/md2docx",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "基于 pandoc 的 Markdown 转 Word 工具,自动格式化 Markdown,支持自定义样式,AI 友好,用户友好。",
5
5
  "keywords": [
6
6
  "converter",