@bytechain.cn/colamd-themes 0.6.1 → 0.6.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 CHANGED
@@ -49,7 +49,7 @@ After installation, open a `.md` file and run **ColaView MD: Show Preview** from
49
49
  ### HTML / PDF Export
50
50
 
51
51
  - **`export-html`** — render Markdown to a standalone HTML document with theme CSS embedded, Mermaid diagrams and KaTeX math fully rendered
52
- - **`export-pdf`** — render Markdown to PDF via Puppeteer (Chromium); theme colors are preserved with `print-color-adjust: exact`
52
+ - **`export-pdf`** — render Markdown to PDF via Puppeteer (Chromium); theme colors are preserved with `print-color-adjust: exact`. **Every export is content-checked afterwards (v0.6.2)** — paper size, page count, blank pages and deck chrome (PDF-01…05) — and a standalone `check-pdf` command inspects any existing PDF; slide decks enforce 16:9 paper (960×540pt) and deck-page-count parity
53
53
  - **`export`** — batch export multiple files or entire directories to HTML, PDF, or both at once (`--format html,pdf` renders both artifacts in a single renderer/browser lifecycle)
54
54
  - **Token-saving exports (v0.5.8+, default on)** — when the source markdown contains no math (`$$`, `$...$`, `\(..\)`, `\begin{..}`), the inlined base64 KaTeX math fonts (≈96% of the embedded CSS) are stripped from the export artifact, shrinking a typical export from ~1.5 MB (~400k tokens) to ~57 KB (~15k tokens) — ideal when an AI/LLM agent reads the output back. Math documents keep their fonts automatically; `--keep-fonts` forces full font embedding. Money mentions like `$1.5M` are correctly ignored by the math detector
55
55
  - Powered by `@bytechain.cn/colamd/renderer` (2.x library build, requires `@bytechain.cn/colamd@^2.7.13`) — the same CM6 editor as the app runs headless via Puppeteer. Theme CSS is consumed directly as `:root` declarations, `buildExportHTML({ title })` serializes only contract live variables, and mermaid diagrams (Pele SVG) / KaTeX math stay fully rendered offline. Built-in theme names resolve their local contract CSS first. Generated themes target the **2.7.13 contract**, so they carry over unchanged.
@@ -342,6 +342,7 @@ cthemes set-theme my-brand --remove
342
342
  | `color-systems` | List 15 built-in color systems |
343
343
  | `list` | List all generated themes |
344
344
  | `validate <file>` | Validate a theme CSS (2.7 contract + paradigm + slide token rules) or a slides markdown file (directive contract); with a platform compat report |
345
+ | `check-pdf <file>` | Content-check an exported PDF: paper size, page count, blank pages, deck chrome (PDF-01…05); `-d <deck.md>` enables slide parity checks |
345
346
  | `set-theme <name>` | Set, register, or remove export themes |
346
347
  | `export-html <input>` | Export Markdown → standalone HTML |
347
348
  | `export-pdf <input>` | Export Markdown → PDF |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytechain.cn/colamd-themes",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Theme development & export tool for ColaMD — extract formatting, generate themes, and export Markdown to HTML/PDF",
5
5
  "repository": {
6
6
  "type": "git",
@@ -59,6 +59,7 @@ colamd-themes set-theme <name> --remove
59
59
  colamd-themes color-systems [-j]
60
60
  colamd-themes list [-d <dir>]
61
61
  colamd-themes validate <file.css | file.md>
62
+ colamd-themes check-pdf <file.pdf> [-d <deck.md>]
62
63
  ```
63
64
 
64
65
  `validate` accepts theme CSS **and** slides markdown (`.md` → directive contract checks). It prints a **platform compat line** ("平台兼容") — it reports the installed `@bytechain.cn/colamd` version, whether its `themes/contract.json` matches the theme contract (2.7.13 and 2.7.13 are both accepted), and whether the **slide layout system** is available (幻灯片版式: 支持/不支持). On drift it lists missing live variables; treat that as a signal to check the platform changelog or pin `@bytechain.cn/colamd@^2.7.13`.
@@ -223,6 +224,31 @@ colamd-themes validate deck.md
223
224
  - **SLIDES-04/05** (MUST_NOT):页头块字段键 ∉ kicker/label/chapter、deck 键 ∉ logo/brand/title/meta
224
225
  - **SLIDES-06** (MUST_NOT):slide-css 含 `position: absolute/fixed`、`z-index`、伪协议 URL
225
226
 
227
+ ### Export PDF content checks (PDF-01…05, v0.6.2)
228
+
229
+ 导出产物的内容契约(CSS 契约管「进渲染器的」,PDF 契约管「出渲染器的」)。
230
+ `export-pdf` 每次导出后**自动执行**并打印报告;也可对任何已有 PDF 单独检查:
231
+
232
+ ```bash
233
+ colamd-themes check-pdf out.pdf # 自动判定文档/幻灯片
234
+ colamd-themes check-pdf out.pdf -d deck.md # 提供配对 deck → 页数/chrome 检查
235
+ ```
236
+
237
+ - **PDF-01** (MUST):PDF 可解析(pdf-parse 子进程页文本提取,≥1 页)
238
+ - **PDF-02** (MUST):页面尺寸一致;幻灯片导出必须是 16:9 纸型
239
+ (1280×720 @96dpi = **960×540pt**;文档式导出为 A4/Letter,仅查一致性)
240
+ - **PDF-03** (MUST):slide 页数 = deck 页数(提供 `-d deck.md` 或 deck 指令时)——
241
+ 最常见的失真是内容溢出把一页挤出两张纸
242
+ - **PDF-04** (SHOULD):无空白页(某页文本抽取 < 5 字符)
243
+ - **PDF-05** (SHOULD):deck 标题(chrome)出现在 PDF 文本中(去空白比对,
244
+ 规避 Chromium 字形切分插空格)
245
+
246
+ 实现要点:pdf-parse 必须跑在**干净的 `node -e` 子进程**里——pdf.js v1.10 的
247
+ worker 在 tsx/esbuild 转换环境下会确定性误报 `bad XRef entry`(对真实
248
+ Chromium 导出文件同样成立);buffer 走 stdin,结果走 stdout JSON,
249
+ pdf-parse 的解析路径由 CLI 侧 `createRequire` 解析后经环境变量传入。
250
+ MUST 违规使命令以退出码 1 结束。
251
+
226
252
  ### PPT style tokens (--slide-*)
227
253
 
228
254
  Upstream `slides.css` defines ~26 `--slide-*` tokens on `:root` (title font/size/weight/tracking, kicker, chrome, page padding, KPI/quote sizes). Themes can override them — **`--ppt [style]`** emits a token section into the generated theme: