@v1hz/md2docx 1.0.0 → 1.0.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 +20 -6
- package/package.json +1 -1
- package/src/paths.ts +9 -7
package/README.md
CHANGED
|
@@ -21,28 +21,42 @@
|
|
|
21
21
|
- [Bun](https://bun.sh) ≥ 1.3
|
|
22
22
|
- [pandoc](https://pandoc.org)(可选,需导出 Word 时安装)
|
|
23
23
|
|
|
24
|
-
###
|
|
24
|
+
### 通过 npx(推荐,无需安装)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx @v1hz/md2docx README.md
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 全局安装
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g @v1hz/md2docx
|
|
34
|
+
md2docx README.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 从源码运行
|
|
25
38
|
|
|
26
39
|
```bash
|
|
27
40
|
git clone https://github.com/WXY-V1hZ/md2docx.git
|
|
28
41
|
cd md2docx
|
|
29
42
|
bun install
|
|
43
|
+
bun run src/index.ts docs/example.md
|
|
30
44
|
```
|
|
31
45
|
|
|
32
46
|
## 快速开始
|
|
33
47
|
|
|
34
48
|
```bash
|
|
35
49
|
# 处理 Markdown 并生成 Word 文档
|
|
36
|
-
|
|
50
|
+
npx @v1hz/md2docx docs/example.md
|
|
37
51
|
|
|
38
52
|
# 只预处理,不调用 pandoc
|
|
39
|
-
|
|
53
|
+
npx @v1hz/md2docx docs/example.md --pandoc.enabled false
|
|
40
54
|
|
|
41
55
|
# 指定输出路径
|
|
42
|
-
|
|
56
|
+
npx @v1hz/md2docx docs/example.md -o output/example.docx
|
|
43
57
|
|
|
44
58
|
# 使用自定义配置文件
|
|
45
|
-
|
|
59
|
+
npx @v1hz/md2docx docs/example.md --config ./my-config.json
|
|
46
60
|
```
|
|
47
61
|
|
|
48
62
|
## 配置
|
|
@@ -52,7 +66,7 @@ bun run src/index.ts docs/example.md --config ./my-config.json
|
|
|
52
66
|
所有配置项均可通过命令行覆盖:
|
|
53
67
|
|
|
54
68
|
```bash
|
|
55
|
-
|
|
69
|
+
npx @v1hz/md2docx docs/example.md --figureCaption.enabled false
|
|
56
70
|
```
|
|
57
71
|
|
|
58
72
|
### 配置项概览
|
package/package.json
CHANGED
package/src/paths.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolve } from "path";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export const CONFIG_PATH = "config/config.json";
|
|
3
|
+
const PKG_DIR = resolve(import.meta.dir, "..");
|
|
5
4
|
|
|
6
|
-
/**
|
|
7
|
-
export const
|
|
5
|
+
/** 默认配置文件路径(相对于包安装目录) */
|
|
6
|
+
export const CONFIG_PATH = resolve(PKG_DIR, "config/config.json");
|
|
8
7
|
|
|
9
|
-
/**
|
|
8
|
+
/** 默认配置 schema 路径(相对于包安装目录) */
|
|
9
|
+
export const CONFIG_SCHEMA_PATH = resolve(PKG_DIR, "config/config.schema.json");
|
|
10
|
+
|
|
11
|
+
/** 临时文件根目录(相对于当前工作目录) */
|
|
10
12
|
export const TMP_DIR = "tmp";
|
|
11
13
|
|
|
12
|
-
/**
|
|
14
|
+
/** 预处理模块的输出目录(相对于当前工作目录) */
|
|
13
15
|
export function preprocessDir(baseName: string): string {
|
|
14
16
|
return `${TMP_DIR}/preprocess/${baseName}`;
|
|
15
17
|
}
|