@wenyan-md/cli 1.0.1 → 1.0.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/README.md +44 -30
- package/dist/commands/publish.js +1 -1
- package/dist/commands/render.js +1 -1
- package/dist/index.js +8 -2
- package/dist/{commands → types/commands}/publish.d.ts +0 -1
- package/dist/{commands → types/commands}/render.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/{utils.d.ts → types/utils.d.ts} +0 -1
- package/package.json +26 -12
- package/dist/commands/publish.d.ts.map +0 -1
- package/dist/commands/render.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,21 +4,37 @@
|
|
|
4
4
|
|
|
5
5
|
# 文颜 CLI
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
「文颜」是一款多平台排版美化工具,让你将 Markdown 一键发布至微信公众号、知乎、今日头条等主流写作平台。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**文颜**现已推出多个版本:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
* [macOS App Store 版](https://github.com/caol64/wenyan) - MAC 桌面应用
|
|
12
|
+
* [Windows + Linux 版](https://github.com/caol64/wenyan-pc) - 跨平台桌面应用
|
|
13
|
+
* [CLI 版本](https://github.com/caol64/wenyan-cli) - CI/CD 或脚本自动化发布公众号文章
|
|
14
|
+
* [MCP 版本](https://github.com/caol64/wenyan-mcp) - 让 AI 自动发布公众号文章
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
本项目是 **文颜的 CLI 版本**。
|
|
14
17
|
|
|
15
|
-
##
|
|
18
|
+
## 功能
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
* 使用内置主题对 Markdown 内容排版
|
|
21
|
+
* 支持图片自动上传
|
|
22
|
+
* 支持数学公式渲染
|
|
23
|
+
* 一键发布文章到微信公众号草稿箱
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
## 主题效果
|
|
26
|
+
|
|
27
|
+
👉 [内置主题预览](https://yuzhi.tech/docs/wenyan/theme)
|
|
28
|
+
|
|
29
|
+
文颜采用了多个开源的 Typora 主题,在此向各位作者表示感谢:
|
|
30
|
+
|
|
31
|
+
- [Orange Heart](https://github.com/evgo2017/typora-theme-orange-heart)
|
|
32
|
+
- [Rainbow](https://github.com/thezbm/typora-theme-rainbow)
|
|
33
|
+
- [Lapis](https://github.com/YiNNx/typora-theme-lapis)
|
|
34
|
+
- [Pie](https://github.com/kevinzhao2233/typora-theme-pie)
|
|
35
|
+
- [Maize](https://github.com/BEATREE/typora-maize-theme)
|
|
36
|
+
- [Purple](https://github.com/hliu202/typora-purple-theme)
|
|
37
|
+
- [物理猫-薄荷](https://github.com/sumruler/typora-theme-phycat)
|
|
22
38
|
|
|
23
39
|
## 安装
|
|
24
40
|
|
|
@@ -26,8 +42,6 @@
|
|
|
26
42
|
npm install -g @wenyan-md/cli
|
|
27
43
|
```
|
|
28
44
|
|
|
29
|
-
---
|
|
30
|
-
|
|
31
45
|
## 基本用法
|
|
32
46
|
|
|
33
47
|
主命令为:
|
|
@@ -36,8 +50,6 @@ npm install -g @wenyan-md/cli
|
|
|
36
50
|
wenyan <command> [options]
|
|
37
51
|
```
|
|
38
52
|
|
|
39
|
-
---
|
|
40
|
-
|
|
41
53
|
## 环境变量
|
|
42
54
|
|
|
43
55
|
某些功能(如发布到微信公众号)需要配置以下环境变量:
|
|
@@ -72,8 +84,6 @@ $env:WECHAT_APP_ID="xxx"; $env:WECHAT_APP_SECRET="yyy"; wenyan publish "your mar
|
|
|
72
84
|
|
|
73
85
|
控制面板 → 系统和安全 → 系统 → 高级系统设置 → 环境变量 → 添加 `WECHAT_APP_ID` 和 `WECHAT_APP_SECRET`。
|
|
74
86
|
|
|
75
|
-
---
|
|
76
|
-
|
|
77
87
|
## 子命令
|
|
78
88
|
|
|
79
89
|
`publish`
|
|
@@ -87,10 +97,26 @@ $env:WECHAT_APP_ID="xxx"; $env:WECHAT_APP_SECRET="yyy"; wenyan publish "your mar
|
|
|
87
97
|
### 选项
|
|
88
98
|
|
|
89
99
|
- `-t`,主题id,默认`default`
|
|
100
|
+
- default
|
|
101
|
+
- orangeheart
|
|
102
|
+
- rainbow
|
|
103
|
+
- lapis
|
|
104
|
+
- pie
|
|
105
|
+
- maize
|
|
106
|
+
- purple
|
|
107
|
+
- phycat
|
|
90
108
|
- `-h`,代码高亮主题,默认`solarized-light`
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
109
|
+
- atom-one-dark
|
|
110
|
+
- atom-one-light
|
|
111
|
+
- dracula
|
|
112
|
+
- github-dark
|
|
113
|
+
- github
|
|
114
|
+
- monokai
|
|
115
|
+
- solarized-dark
|
|
116
|
+
- solarized-light
|
|
117
|
+
- xcode
|
|
118
|
+
- 代码块默认使用 Mac 风格,如要关闭:`--no-mac-style`
|
|
119
|
+
- 链接默认转脚注,如要关闭:`--no-footnote`
|
|
94
120
|
|
|
95
121
|
## 示例
|
|
96
122
|
|
|
@@ -106,15 +132,11 @@ wenyan publish "# Hello, Wenyan" -t lapis -h solarized-light
|
|
|
106
132
|
cat example.md | wenyan publish -t lapis -h solarized-light --no-mac-style
|
|
107
133
|
```
|
|
108
134
|
|
|
109
|
-
---
|
|
110
|
-
|
|
111
135
|
## 微信公众号 IP 白名单
|
|
112
136
|
|
|
113
137
|
请务必将服务器 IP 加入公众号平台的 IP 白名单,以确保上传接口调用成功。
|
|
114
138
|
详细配置说明请参考:[https://yuzhi.tech/docs/wenyan/upload](https://yuzhi.tech/docs/wenyan/upload)
|
|
115
139
|
|
|
116
|
-
---
|
|
117
|
-
|
|
118
140
|
## 配置说明(Frontmatter)
|
|
119
141
|
|
|
120
142
|
为了可以正确上传文章,需要在每一篇 Markdown 文章的开头添加一段`frontmatter`,提供`title`、`cover`两个字段:
|
|
@@ -132,8 +154,6 @@ cover: /Users/lei/Downloads/result_image.jpg
|
|
|
132
154
|
* 如果正文有至少一张图片,可省略,此时将使用其中一张作为封面;
|
|
133
155
|
* 如果正文无图片,则必须提供 cover。
|
|
134
156
|
|
|
135
|
-
---
|
|
136
|
-
|
|
137
157
|
## 关于图片自动上传
|
|
138
158
|
|
|
139
159
|
* 支持图片路径:
|
|
@@ -141,8 +161,6 @@ cover: /Users/lei/Downloads/result_image.jpg
|
|
|
141
161
|
* 本地路径(如:`/Users/lei/Downloads/result_image.jpg`)
|
|
142
162
|
* 网络路径(如:`https://example.com/image.jpg`)
|
|
143
163
|
|
|
144
|
-
---
|
|
145
|
-
|
|
146
164
|
## 示例文章格式
|
|
147
165
|
|
|
148
166
|
```md
|
|
@@ -160,14 +178,10 @@ cover: /Users/lei/Downloads/result_image.jpg
|
|
|
160
178
|

|
|
161
179
|
```
|
|
162
180
|
|
|
163
|
-
---
|
|
164
|
-
|
|
165
181
|
## 赞助
|
|
166
182
|
|
|
167
183
|
如果您觉得不错,可以给我家猫咪买点罐头吃。[喂猫❤️](https://yuzhi.tech/sponsor)
|
|
168
184
|
|
|
169
|
-
---
|
|
170
|
-
|
|
171
185
|
## License
|
|
172
186
|
|
|
173
187
|
Apache License Version 2.0
|
package/dist/commands/publish.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function publishCommand(inputContent, options) {
|
|
|
10
10
|
}
|
|
11
11
|
inputContent = await readStdin();
|
|
12
12
|
}
|
|
13
|
-
const gzhContent = await getGzhContent(inputContent, options["theme"], options["highlight"], options["macStyle"]);
|
|
13
|
+
const gzhContent = await getGzhContent(inputContent, options["theme"], options["highlight"], options["macStyle"], options["footnote"]);
|
|
14
14
|
if (!gzhContent.title) {
|
|
15
15
|
console.error("未能找到文章标题");
|
|
16
16
|
process.exit(1);
|
package/dist/commands/render.js
CHANGED
|
@@ -9,7 +9,7 @@ export async function renderCommand(inputContent, options) {
|
|
|
9
9
|
}
|
|
10
10
|
inputContent = await readStdin();
|
|
11
11
|
}
|
|
12
|
-
const gzhContent = await getGzhContent(inputContent, options["theme"], options["highlight"], options["macStyle"]);
|
|
12
|
+
const gzhContent = await getGzhContent(inputContent, options["theme"], options["highlight"], options["macStyle"], options["footnote"]);
|
|
13
13
|
console.log(gzhContent.content);
|
|
14
14
|
// process.exit(0);
|
|
15
15
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,10 @@ program
|
|
|
17
17
|
.argument("[input-content]", "content of the input markdown file")
|
|
18
18
|
.option("-t, --theme <theme-id>", "ID of the theme to use", "default")
|
|
19
19
|
.option("-h, --highlight <highlight-theme-id>", "ID of the code highlight theme to use", "solarized-light")
|
|
20
|
-
.option("
|
|
20
|
+
.option("--mac-style", "display codeblock with mac style", true)
|
|
21
|
+
.option("--no-mac-style", "disable mac style")
|
|
22
|
+
.option("--footnote", "convert link to footnote", true)
|
|
23
|
+
.option("--no-footnote", "disable footnote")
|
|
21
24
|
.action(publishCommand);
|
|
22
25
|
program
|
|
23
26
|
.command("render")
|
|
@@ -25,6 +28,9 @@ program
|
|
|
25
28
|
.argument("[input-content]", "content of the input markdown file")
|
|
26
29
|
.option("-t, --theme <theme-id>", "ID of the theme to use", "default")
|
|
27
30
|
.option("-h, --highlight <highlight-theme-id>", "ID of the code highlight theme to use", "solarized-light")
|
|
28
|
-
.option("
|
|
31
|
+
.option("--mac-style", "display codeblock with mac style", true)
|
|
32
|
+
.option("--no-mac-style", "disable mac style")
|
|
33
|
+
.option("--footnote", "convert link to footnote", true)
|
|
34
|
+
.option("--no-footnote", "disable footnote")
|
|
29
35
|
.action(renderCommand);
|
|
30
36
|
program.parse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wenyan-md/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A CLI tool for Wenyan markdown rendering & publishing",
|
|
5
5
|
"author": "Lei <caol64@gmail.com> (https://github.com/caol64)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"keywords": [
|
|
7
|
+
"keywords": [
|
|
8
|
+
"公众号",
|
|
9
|
+
"markdown",
|
|
10
|
+
"文颜",
|
|
11
|
+
"wenyan",
|
|
12
|
+
"wechat",
|
|
13
|
+
"publishing",
|
|
14
|
+
"renderer"
|
|
15
|
+
],
|
|
8
16
|
"type": "module",
|
|
9
17
|
"bin": {
|
|
10
18
|
"wenyan": "./bin/cli.js"
|
|
11
19
|
},
|
|
12
20
|
"main": "./dist/index.js",
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
14
22
|
"files": [
|
|
15
23
|
"dist",
|
|
16
24
|
"bin"
|
|
17
25
|
],
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
"homepage": "https://github.com/caol64/wenyan-cli#readme",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/caol64/wenyan-cli.git"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/caol64/wenyan-cli/issues"
|
|
24
33
|
},
|
|
25
|
-
"packageManager": "pnpm@10.7.1",
|
|
26
34
|
"dependencies": {
|
|
27
|
-
"@wenyan-md/core": "^1.0.
|
|
35
|
+
"@wenyan-md/core": "^1.0.8",
|
|
28
36
|
"commander": "^14.0.0"
|
|
29
37
|
},
|
|
30
38
|
"devDependencies": {
|
|
@@ -32,5 +40,11 @@
|
|
|
32
40
|
"dotenv-cli": "^10.0.0",
|
|
33
41
|
"tsx": "^4.20.5",
|
|
34
42
|
"typescript": "^5.9.2"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc",
|
|
46
|
+
"dev": "tsx src/index.ts",
|
|
47
|
+
"test:render": "pnpm build && cat test/publish.md | node ./bin/cli.js render",
|
|
48
|
+
"test:publish": "pnpm build && cat test/publish.md | pnpm dotenv -e .env.test -- node ./bin/cli.js publish -t lapis"
|
|
35
49
|
}
|
|
36
|
-
}
|
|
50
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AAIA,UAAU,aAAa;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,iBAiChF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,aAAa,iBAqB3F"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAQjD"}
|