markdown-paper 3.1.1 → 3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [3.2.0](https://github.com/LeafYeeXYZ/MarkdownPaper/compare/v3.1.1...v3.2.0) (2026-03-19)
6
+
7
+
8
+ ### Features
9
+
10
+ * 支持自动使用系统安装的Chrome ([128528b](https://github.com/LeafYeeXYZ/MarkdownPaper/commit/128528ba10b64246b96b03e64ec688f8c0f83321))
11
+
5
12
  ## [3.1.1](https://github.com/LeafYeeXYZ/MarkdownPaper/compare/v3.1.0...v3.1.1) (2025-06-12)
6
13
 
7
14
 
package/README.md CHANGED
@@ -74,7 +74,13 @@ bun add -g markdown-paper
74
74
 
75
75
  > 如果您安装过旧版本的 `MarkdownPaper` (小于 `2.0.0`), 请先卸载旧版本再安装新版本
76
76
 
77
- ## 4 生成论文
77
+ ## 4 安装 `Chrome` 浏览器
78
+
79
+ `MarkdownPaper` 使用 `Puppeteer` 库将 `Markdown` 转换为 `PDF` 文件, 需要依赖 `Chrome` 浏览器; 请确保您的系统中安装了 `Chrome` 浏览器, 如果没有安装, 请前往 [Google Chrome 官网](https://www.google.com/chrome/) 下载并安装
80
+
81
+ `MarkdownPaper` 默认会读取 `C:\Program Files\Google\Chrome\Application\chrome.exe` (Windows) 或 `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` (macOS) 路径下的 `Chrome` 浏览器, 如果您的 `Chrome` 浏览器安装在其他路径, 请在生成论文时使用 `--browser <path>` 选项指定浏览器路径
82
+
83
+ ## 5 生成论文
78
84
 
79
85
  运行 `mdp` 命令以使用 `MarkdownPaper` 命令行工具从 `Markdown` 文件生成论文
80
86
 
@@ -91,6 +97,8 @@ mdp themes
91
97
  mdp example.md # 可以省略 .md 后缀
92
98
  ```
93
99
 
100
+ > 注: 如果自带模板无法满足您的需求, 您也可以在 `Markdown` 文件中直接书写 `<style></style>` 等 HTML 标签来实现自定义样式, 但请注意这可能会影响到论文的格式和样式
101
+
94
102
  # 模板说明
95
103
 
96
104
  `/lib/types.ts` 中的 `MarkdownnPaperTheme` 类型定义了论文模板; 模板制作完成后, 在 `/lib/types.ts` 中导入并添加即可使用
package/bin/mdp.ts CHANGED
@@ -8,6 +8,15 @@ import { version } from '../package.json'
8
8
 
9
9
  const program = new Command()
10
10
  const cwd = process.cwd()
11
+ let browser = '/usr/bin/google-chrome'
12
+ switch (process.platform) {
13
+ case 'win32':
14
+ browser = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
15
+ break
16
+ case 'darwin':
17
+ browser = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
18
+ break
19
+ }
11
20
 
12
21
  program
13
22
  .name('mdp')
@@ -20,6 +29,7 @@ program
20
29
  .option('--docx --output-docx', '输出DOCX文件', false)
21
30
  .option('--hide-footer', '隐藏页脚页码', false)
22
31
  .option('--punctuation <zh/en/origin>', '标点符号格式', 'zh')
32
+ .option('--browser <path>', 'Puppeteer浏览器路径 (默认为系统安装的Chrome)', browser)
23
33
  .command('themes', '显示所有可用的论文模板')
24
34
  .action((markdown, options) => {
25
35
  console.log('开始生成')
package/lib/main.ts CHANGED
@@ -6,7 +6,7 @@ import { asBlob } from 'html-docx-js-typescript'
6
6
  import katexCss from 'katex/dist/katex.css' with { type: 'text' }
7
7
  import { marked } from 'marked'
8
8
  import markedKatex from 'marked-katex-extension'
9
- import puppeteer from 'puppeteer'
9
+ import puppeteer from 'puppeteer-core'
10
10
  import { type MarkdownPaperOptions, themes } from './types'
11
11
 
12
12
  /**
@@ -43,7 +43,9 @@ export async function render(options: MarkdownPaperOptions): Promise<void> {
43
43
  return match
44
44
  }
45
45
  })
46
- const browser = await puppeteer.launch()
46
+ const browser = await puppeteer.launch({
47
+ executablePath: options.browser,
48
+ })
47
49
  const page = await browser.newPage()
48
50
  await page.setContent(html)
49
51
  await page.evaluate(theme.script)
package/lib/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PDFOptions } from 'puppeteer'
1
+ import type { PDFOptions } from 'puppeteer-core'
2
2
  import { z } from 'zod'
3
3
  import { themeAPS } from './themes/aps'
4
4
 
@@ -28,6 +28,7 @@ export const cliOptions = z.object({
28
28
  outputDocx: z.boolean(),
29
29
  hideFooter: z.boolean(),
30
30
  punctuation: z.enum(['zh', 'en', 'origin']),
31
+ browser: z.string(),
31
32
  })
32
33
 
33
34
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-paper",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "author": {
5
5
  "name": "LeafYeeXYZ",
6
6
  "email": "xiaoyezi@leafyee.xyz"
@@ -10,7 +10,7 @@
10
10
  "html-docx-js-typescript": "^0.1.5",
11
11
  "marked": "^12.0.2",
12
12
  "marked-katex-extension": "^5.1.4",
13
- "puppeteer": "^22.15.0",
13
+ "puppeteer-core": "^24.39.1",
14
14
  "zod": "^3.25.56"
15
15
  },
16
16
  "peerDependencies": {
package/bun.lockb DELETED
Binary file