@lyhue1991/wxgzh 0.1.1 → 0.1.2
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 +27 -46
- package/dist/core/converter.js +30 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,31 +12,40 @@
|
|
|
12
12
|
- 支持主题样式、自定义 CSS、自动摘要、封面图生成。
|
|
13
13
|
- 也支持分步执行,便于你单独检查 HTML、封面或发布结果。
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
**操作方法**
|
|
16
|
+
|
|
17
|
+
* step1: 一键安装(要求:Node.js >= 18)
|
|
16
18
|
|
|
17
19
|
```bash
|
|
18
|
-
wxgzh
|
|
20
|
+
npm install -g @lyhue1991/wxgzh
|
|
21
|
+
```
|
|
22
|
+
安装完成后可直接使用 `wxgzh` 命令。
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
* step2: 一键配置 (提前准备好微信公众号AppID和 AppSecret , 并配置好IP白名单)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
wxgzh config --appid 你的AppID --appsecret 你的AppSecret
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
* step3: 一键投稿 (将本地markdown文章直接投递到公众号草稿箱, 人工确认后即可发布)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
wxgzh article.md --author 文章作者姓名
|
|
19
36
|
```
|
|
20
37
|
|
|
21
38
|
这条命令会自动执行:
|
|
22
39
|
|
|
23
40
|
1. 读取 `article.md`
|
|
24
41
|
2. 转换成公众号可用 HTML
|
|
25
|
-
3.
|
|
42
|
+
3. 上传正文中的本地图片和非微信图床图片到微信公众号图床
|
|
26
43
|
4. 自动生成封面图(如果你没有提供)
|
|
27
44
|
5. 提交到微信公众号草稿箱
|
|
28
45
|
|
|
29
|
-
## 安装
|
|
30
|
-
|
|
31
|
-
要求:Node.js >= 18
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install -g @lyhue1991/wxgzh
|
|
35
|
-
```
|
|
36
46
|
|
|
37
|
-
安装完成后可直接使用 `wxgzh` 命令。
|
|
38
47
|
|
|
39
|
-
##
|
|
48
|
+
## 二、配置说明
|
|
40
49
|
|
|
41
50
|
### 1. 如何获取公众号 `appid` 和 `appsecret`
|
|
42
51
|
|
|
@@ -99,8 +108,6 @@ wxgzh config --list-themes
|
|
|
99
108
|
当前内置主题来自 `styles/` 目录,例如:`default`、`blue`、`green`、`red`、`yellow`、`brown`、`black`、`orange`。
|
|
100
109
|
|
|
101
110
|
|
|
102
|
-
|
|
103
|
-
|
|
104
111
|
## 三、快速流程
|
|
105
112
|
|
|
106
113
|
最常见用法:
|
|
@@ -374,7 +381,10 @@ enableComment: true
|
|
|
374
381
|
|
|
375
382
|
命令行参数优先级高于 Front Matter,Front Matter 又高于默认配置。
|
|
376
383
|
|
|
377
|
-
|
|
384
|
+
|
|
385
|
+
## 六,备忘清单
|
|
386
|
+
|
|
387
|
+
### 1. 支持的 Markdown 内容
|
|
378
388
|
|
|
379
389
|
本项目当前重点支持这些常见内容:
|
|
380
390
|
|
|
@@ -386,9 +396,10 @@ enableComment: true
|
|
|
386
396
|
- 表格
|
|
387
397
|
- 数学公式(行内与块级)
|
|
388
398
|
|
|
389
|
-
|
|
399
|
+
### 2. 常用命令速查
|
|
390
400
|
|
|
391
401
|
```bash
|
|
402
|
+
wxgzh --help
|
|
392
403
|
wxgzh article.md
|
|
393
404
|
wxgzh config --list
|
|
394
405
|
wxgzh config --list-themes
|
|
@@ -398,34 +409,4 @@ wxgzh cover --title "我的文章" --to .wxgzh/cover.jpg
|
|
|
398
409
|
wxgzh publish --article .wxgzh/article.html --cover .wxgzh/cover.jpg
|
|
399
410
|
```
|
|
400
411
|
|
|
401
|
-
## 开发与构建
|
|
402
|
-
|
|
403
|
-
开发环境安装依赖:
|
|
404
|
-
|
|
405
|
-
```bash
|
|
406
|
-
npm install
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
类型检查:
|
|
410
|
-
|
|
411
|
-
```bash
|
|
412
|
-
npm run typecheck
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
构建:
|
|
416
|
-
|
|
417
|
-
```bash
|
|
418
|
-
npm run build
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
查看帮助:
|
|
422
|
-
|
|
423
|
-
```bash
|
|
424
|
-
node dist/cli/index.js --help
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
## 说明
|
|
428
412
|
|
|
429
|
-
- 配置文件保存在用户目录下,不会写进项目源码目录。
|
|
430
|
-
- `dist/` 是编译输出目录,日常修改应以 `src/` 为准。
|
|
431
|
-
- 如果一键发布失败,建议改用“分步流程”逐步检查 `HTML`、图片上传和封面图。
|
package/dist/core/converter.js
CHANGED
|
@@ -178,6 +178,35 @@ q table:last-child {
|
|
|
178
178
|
margin-bottom: 0 !important;
|
|
179
179
|
}
|
|
180
180
|
`;
|
|
181
|
+
const WECHAT_LAYOUT_INLINE_CSS = `
|
|
182
|
+
p,
|
|
183
|
+
h1,
|
|
184
|
+
h2,
|
|
185
|
+
h3,
|
|
186
|
+
h4,
|
|
187
|
+
h5,
|
|
188
|
+
h6,
|
|
189
|
+
ul,
|
|
190
|
+
ol,
|
|
191
|
+
dl,
|
|
192
|
+
blockquote,
|
|
193
|
+
q,
|
|
194
|
+
pre,
|
|
195
|
+
hr,
|
|
196
|
+
section.img-wrapper,
|
|
197
|
+
section.tbl-wrapper,
|
|
198
|
+
section.math-block {
|
|
199
|
+
margin-left: 0 !important;
|
|
200
|
+
margin-right: 0 !important;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
section.img-wrapper,
|
|
204
|
+
section.tbl-wrapper,
|
|
205
|
+
section.math-block {
|
|
206
|
+
width: 100% !important;
|
|
207
|
+
box-sizing: border-box !important;
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
181
210
|
const WECHAT_TABLE_INLINE_CSS = `
|
|
182
211
|
section.tbl-wrapper {
|
|
183
212
|
margin: 1.4em 3% !important;
|
|
@@ -616,7 +645,7 @@ async function renderMarkdownToHtml(body, metadata) {
|
|
|
616
645
|
const articleHtml = $('article').html() ?? '';
|
|
617
646
|
const baseHtml = createDocumentHtml(articleHtml, metadata);
|
|
618
647
|
const inlinedHtml = (0, css_inline_1.inline)(baseHtml, {
|
|
619
|
-
extraCss: `${themeCss}\n${HIGHLIGHT_INLINE_CSS}\n${WECHAT_BLOCKQUOTE_INLINE_CSS}\n${WECHAT_TABLE_INLINE_CSS}\n${WECHAT_MATH_INLINE_CSS}\n${customCss}`,
|
|
648
|
+
extraCss: `${themeCss}\n${HIGHLIGHT_INLINE_CSS}\n${WECHAT_BLOCKQUOTE_INLINE_CSS}\n${WECHAT_TABLE_INLINE_CSS}\n${WECHAT_MATH_INLINE_CSS}\n${WECHAT_LAYOUT_INLINE_CSS}\n${customCss}`,
|
|
620
649
|
keepAtRules: true,
|
|
621
650
|
applyWidthAttributes: false,
|
|
622
651
|
applyHeightAttributes: false
|