@liustack/pagepress 0.5.1 → 0.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # PagePress
2
2
 
3
- A web content rendering toolkit (CLI) designed for **AI Agents**, converting HTML, Markdown, and URLs into high-quality **PDF** or **PNG** images.
3
+ A web content rendering toolkit (CLI) designed for **AI Agents**, converting local HTML and Markdown files into high-quality **PDF** or **PNG** images.
4
4
 
5
5
  中文说明请见:[README.zh-CN.md](README.zh-CN.md)
6
6
 
@@ -8,7 +8,7 @@ A web content rendering toolkit (CLI) designed for **AI Agents**, converting HTM
8
8
 
9
9
  - **Unified CLI**: One tool (`pagepress`) for both PDF and image generation
10
10
  - **AI Agent friendly**: Includes a detailed SKILL.md guide with scenario routing
11
- - **Multiple inputs**: Local HTML, Markdown files, or remote URLs
11
+ - **Local files only**: Accepts local HTML and Markdown files (remote URLs are not supported for security)
12
12
  - **Rich templates**:
13
13
  - **PDF**: Apple style, GitHub style, magazine layout (Magazine)
14
14
  - **Image**: 8 presets — OG cards, infographics, posters, banners, Twitter/X cards, YouTube thumbnails, Xiaohongshu covers, WeChat covers
@@ -44,8 +44,6 @@ pagepress pdf -i document.md -o output.pdf --template default
44
44
  # Local HTML file to PDF
45
45
  pagepress pdf -i page.html -o output.pdf
46
46
 
47
- # Render a web page (as-is)
48
- pagepress pdf -i https://example.com -o webpage.pdf
49
47
  ```
50
48
 
51
49
  **Supported templates**:
@@ -55,7 +53,7 @@ pagepress pdf -i https://example.com -o webpage.pdf
55
53
 
56
54
  ### 2. Generate Images
57
55
 
58
- Render HTML/URLs into PNG images, suitable for social share cards, posters, and long screenshots.
56
+ Render local HTML into PNG images, suitable for social share cards, posters, and infographics.
59
57
 
60
58
  For OG cards, posters, and banners, the visuals should be generated based on workspace brand assets (logo, colors, fonts, imagery), commonly located in `assets/`, `public/`, or `src/assets/`.
61
59
 
@@ -79,8 +77,6 @@ pagepress shot -i card.html -o og.png --preset og
79
77
  # Generate a long infographic
80
78
  pagepress shot -i stats.html -o infographic.png --preset infographic
81
79
 
82
- # Webpage screenshot
83
- pagepress shot -i https://example.com -o screenshot.png
84
80
  ```
85
81
 
86
82
  **Supported presets**:
@@ -117,8 +113,8 @@ pagepress shot -i https://example.com -o screenshot.png
117
113
 
118
114
  This project includes two skill guides for AI Agents (such as Claude, ChatGPT):
119
115
 
120
- - [web-to-pdf/SKILL.md](skills/web-to-pdf/SKILL.md) — PDF generation (Markdown beautification, templates, HTML/URL printing)
121
- - [web-to-png/SKILL.md](skills/web-to-png/SKILL.md) — PNG generation (OG cards, infographics, posters, banners, screenshots)
116
+ - [web-to-pdf/SKILL.md](skills/web-to-pdf/SKILL.md) — PDF generation (Markdown beautification, templates, HTML printing)
117
+ - [web-to-png/SKILL.md](skills/web-to-png/SKILL.md) — PNG generation (OG cards, infographics, posters, banners, social cards)
122
118
 
123
119
  Agents can automatically choose the appropriate commands and parameters based on natural language instructions (for example, "generate a poster" or "convert this document to PDF").
124
120
 
package/README.zh-CN.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # PagePress
2
2
 
3
- 一套专为 **AI Agent** 设计的 Web 内容渲染工具集(CLI),可将 HTML、Markdown、URL 转换为高质量的 **PDF** 或 **PNG** 图像。
3
+ 一套专为 **AI Agent** 设计的 Web 内容渲染工具集(CLI),可将本地 HTML、Markdown 文件转换为高质量的 **PDF** 或 **PNG** 图像。
4
4
 
5
5
  ## ✨ 特性
6
6
 
7
7
  - **统一 CLI**:一个工具 (`pagepress`) 搞定 PDF 和 Image 生成
8
8
  - **AI Agent 友好**:包含详细的 SKILL.md 指南,支持场景路由
9
- - **多种输入**:支持本地 HTML、Markdown 文件或远程 URL
9
+ - **仅本地文件**:支持本地 HTML、Markdown 文件(出于安全考虑不支持远程 URL
10
10
  - **丰富模板**:
11
11
  - **PDF**: Apple 风格、GitHub 风格、杂志排版 (Magazine)
12
12
  - **Image**: 8 种预设 — OG 卡片、信息图、海报、横幅、Twitter/X 卡片、YouTube 缩略图、小红书封面、微信公众号封面
@@ -42,8 +42,6 @@ pagepress pdf -i document.md -o output.pdf --template default
42
42
  # 本地 HTML 文件转 PDF
43
43
  pagepress pdf -i page.html -o output.pdf
44
44
 
45
- # 网页打印(原样渲染)
46
- pagepress pdf -i https://example.com -o webpage.pdf
47
45
  ```
48
46
 
49
47
  **支持的模板**:
@@ -53,7 +51,7 @@ pagepress pdf -i https://example.com -o webpage.pdf
53
51
 
54
52
  ### 2. 生成图像
55
53
 
56
- HTML/URL 渲染为 PNG 图像,适合社交分享卡片、海报、长图截屏。
54
+ 将本地 HTML 渲染为 PNG 图像,适合社交分享卡片、海报、信息图。
57
55
 
58
56
  对于 OG 卡片、海报、横幅,视觉应基于工作区的品牌资源(logo、颜色、字体、素材)生成,常见目录包括 `assets/`、`public/`、`src/assets/`。
59
57
 
@@ -77,8 +75,6 @@ pagepress shot -i card.html -o og.png --preset og
77
75
  # 生成信息长图
78
76
  pagepress shot -i stats.html -o infographic.png --preset infographic
79
77
 
80
- # 网页截图
81
- pagepress shot -i https://example.com -o screenshot.png
82
78
  ```
83
79
 
84
80
  **支持的预设**:
@@ -115,8 +111,8 @@ pagepress shot -i https://example.com -o screenshot.png
115
111
 
116
112
  本项目包含两份 AI Agent 技能指南(适用于 Claude、ChatGPT 等):
117
113
 
118
- - [web-to-pdf/SKILL.md](skills/web-to-pdf/SKILL.md) — PDF 生成(Markdown 美化、模板、HTML/URL 打印)
119
- - [web-to-png/SKILL.md](skills/web-to-png/SKILL.md) — PNG 生成(OG 卡片、信息图、海报、横幅、网页截图)
114
+ - [web-to-pdf/SKILL.md](skills/web-to-pdf/SKILL.md) — PDF 生成(Markdown 美化、模板、HTML 打印)
115
+ - [web-to-png/SKILL.md](skills/web-to-png/SKILL.md) — PNG 生成(OG 卡片、信息图、海报、横幅、社交卡片)
120
116
 
121
117
  Agent 可以根据用户的自然语言指令(如"生成一张海报"、"把这个文档转成 PDF")自动选择合适的命令和参数。
122
118
 
package/dist/main.js CHANGED
@@ -115,11 +115,8 @@ async function render$1(options) {
115
115
  const inputPath = path.resolve(options.input);
116
116
  let htmlContent;
117
117
  let hasMermaid = false;
118
- if (options.input.startsWith("http")) {
119
- if (safeMode) {
120
- throw new Error("Safe mode does not allow remote URL inputs.");
121
- }
122
- htmlContent = "";
118
+ if (options.input.startsWith("http://") || options.input.startsWith("https://")) {
119
+ throw new Error("Remote URL inputs are not supported. Please provide a local Markdown or HTML file path.");
123
120
  } else if (options.input.endsWith(".md")) {
124
121
  const raw = fs.readFileSync(inputPath, "utf-8");
125
122
  const { data: frontmatter, content } = matter(raw);
@@ -191,11 +188,7 @@ async function render$1(options) {
191
188
  });
192
189
  }
193
190
  const page = await context.newPage();
194
- if (options.input.startsWith("http")) {
195
- await page.goto(options.input, { waitUntil, timeout });
196
- } else {
197
- await page.setContent(htmlContent, { waitUntil, timeout });
198
- }
191
+ await page.setContent(htmlContent, { waitUntil, timeout });
199
192
  const fontCSS = getFontCSS(template.name);
200
193
  if (fontCSS) {
201
194
  await page.addStyleTag({ content: fontCSS });
@@ -323,7 +316,7 @@ async function render$1(options) {
323
316
  }
324
317
  }
325
318
  }
326
- const command$1 = new Command("pdf").description("Render Markdown or HTML to PDF").requiredOption("-i, --input <path>", "Input file path or URL").requiredOption("-o, --output <path>", "Output PDF file path").option("-t, --template <name>", "PDF template (default, github, magazine)", "default").option("--wait-until <state>", "Navigation waitUntil (load, domcontentloaded, networkidle)", "networkidle").option("--timeout <ms>", "Navigation timeout in milliseconds", "30000").option("--safe", "Disable external network requests and JavaScript execution").action(async (options) => {
319
+ const command$1 = new Command("pdf").description("Render Markdown or HTML to PDF").requiredOption("-i, --input <path>", "Input Markdown or HTML file path").requiredOption("-o, --output <path>", "Output PDF file path").option("-t, --template <name>", "PDF template (default, github, magazine)", "default").option("--wait-until <state>", "Navigation waitUntil (load, domcontentloaded, networkidle)", "networkidle").option("--timeout <ms>", "Navigation timeout in milliseconds", "30000").option("--safe", "Disable external network requests and JavaScript execution").action(async (options) => {
327
320
  try {
328
321
  const timeout = Number.parseInt(options.timeout, 10);
329
322
  if (!Number.isFinite(timeout) || timeout < 0) {
@@ -458,10 +451,7 @@ async function render(options) {
458
451
  const page = await context.newPage();
459
452
  const inputPath = path.resolve(options.input);
460
453
  if (options.input.startsWith("http://") || options.input.startsWith("https://")) {
461
- if (safeMode) {
462
- throw new Error("Safe mode does not allow remote URL inputs.");
463
- }
464
- await page.goto(options.input, { waitUntil, timeout });
454
+ throw new Error("Remote URL inputs are not supported. Please provide a local HTML file path.");
465
455
  } else if (fs.existsSync(inputPath)) {
466
456
  const content = fs.readFileSync(inputPath, "utf-8");
467
457
  await page.setContent(content, { waitUntil, timeout });
@@ -510,7 +500,7 @@ async function render(options) {
510
500
  }
511
501
  }
512
502
  }
513
- const command = new Command("shot").description("Capture HTML to PNG image").requiredOption("-i, --input <path>", "Input HTML file path or URL").requiredOption("-o, --output <path>", "Output PNG file path").option("-p, --preset <name>", "Image preset (og, infographic, poster, banner, twitter, youtube, xiaohongshu, wechat)", "og").option("--width <number>", "Custom width in pixels").option("--height <number>", "Custom height in pixels").option("--scale <number>", "Device scale factor", "2").option("--wait-until <state>", "Navigation waitUntil (load, domcontentloaded, networkidle)", "networkidle").option("--timeout <ms>", "Navigation timeout in milliseconds", "30000").option("--safe", "Disable external network requests and JavaScript execution").action(async (options) => {
503
+ const command = new Command("shot").description("Capture HTML to PNG image").requiredOption("-i, --input <path>", "Input HTML file path").requiredOption("-o, --output <path>", "Output PNG file path").option("-p, --preset <name>", "Image preset (og, infographic, poster, banner, twitter, youtube, xiaohongshu, wechat)", "og").option("--width <number>", "Custom width in pixels").option("--height <number>", "Custom height in pixels").option("--scale <number>", "Device scale factor", "2").option("--wait-until <state>", "Navigation waitUntil (load, domcontentloaded, networkidle)", "networkidle").option("--timeout <ms>", "Navigation timeout in milliseconds", "30000").option("--safe", "Disable external network requests and JavaScript execution").action(async (options) => {
514
504
  try {
515
505
  const timeout = Number.parseInt(options.timeout, 10);
516
506
  if (!Number.isFinite(timeout) || timeout < 0) {
@@ -534,7 +524,7 @@ const command = new Command("shot").description("Capture HTML to PNG image").req
534
524
  }
535
525
  });
536
526
  const program = new Command();
537
- program.name("pagepress").description("Convert web pages and Markdown to PDF and images").version("0.1.0");
527
+ program.name("pagepress").description("Convert web pages and Markdown to PDF and images").version("0.6.1");
538
528
  program.addCommand(command$1);
539
529
  program.addCommand(command);
540
530
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liustack/pagepress",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "CLI tool to convert web pages and Markdown to PDF and images",
5
5
  "type": "module",
6
6
  "bin": {