@bytechain.cn/colamd-themes 0.6.0 → 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.
Files changed (39) hide show
  1. package/README.md +24 -5
  2. package/package.json +1 -1
  3. package/skills/colamd-themes/SKILL.md +112 -1
  4. package/themes/8-bit-orbit.css +817 -0
  5. package/themes/README.md +69 -0
  6. package/themes/biennale-yellow.css +577 -0
  7. package/themes/block-frame.css +774 -0
  8. package/themes/blue-professional.css +741 -0
  9. package/themes/bold-poster.css +794 -0
  10. package/themes/broadside.css +837 -0
  11. package/themes/capsule.css +767 -0
  12. package/themes/cartesian.css +584 -0
  13. package/themes/cobalt-grid.css +632 -0
  14. package/themes/coral.css +699 -0
  15. package/themes/creative-mode.css +642 -0
  16. package/themes/daisy-days.css +1052 -0
  17. package/themes/editorial-forest.css +1464 -0
  18. package/themes/editorial-tri-tone.css +811 -0
  19. package/themes/emerald-editorial.css +683 -0
  20. package/themes/grove.css +623 -0
  21. package/themes/long-table.css +782 -0
  22. package/themes/mat.css +848 -0
  23. package/themes/monochrome.css +782 -0
  24. package/themes/neo-grid-bold.css +838 -0
  25. package/themes/peoples-platform.css +843 -0
  26. package/themes/pin-and-paper.css +700 -0
  27. package/themes/pink-script-dark.css +912 -0
  28. package/themes/pink-script.css +290 -0
  29. package/themes/playful.css +774 -0
  30. package/themes/raw-grid.css +814 -0
  31. package/themes/retro-windows.css +767 -0
  32. package/themes/retro-zine.css +814 -0
  33. package/themes/sakura-chroma.css +775 -0
  34. package/themes/scatterbrain.css +726 -0
  35. package/themes/signal.css +872 -0
  36. package/themes/soft-editorial.css +788 -0
  37. package/themes/stencil-tablet.css +922 -0
  38. package/themes/studio.css +767 -0
  39. package/themes/vellum.css +723 -0
package/README.md CHANGED
@@ -34,10 +34,11 @@ After installation, open a `.md` file and run **ColaView MD: Show Preview** from
34
34
  ### Theme Extraction
35
35
 
36
36
  - **URL** — fetch a web page, parse its CSS rules (via `css-tree`), resolve inline styles with specificity calculation, and derive a coherent theme palette
37
+ - **Local HTML template (`from-html`, v0.6.1+)** — extract from a local `.html` file; a sibling `template.json` (when present) supplies authoritative metadata (name, tagline, fonts, scheme, mood, density). Colors come from the template's `:root` custom properties via semantic-name matching with luminance/saturation heuristics as fallback; the palette is sanitized to satisfy the paradigm's luminance ordering (SL-04) and contrast rules (CR-02)
37
38
  - **DOCX** — read Word document styles (H1–H6, tables, code blocks) via mammoth, map to theme variables
38
39
  - **PDF** — extract typography metadata from PDF text using multi-layer heuristic analysis
39
- - **Auto‑detect** — `extract` command automatically routes to the right extractor
40
- - **PPT styling (`--ppt`, v0.6.0+, optional)** — extraction can also emit the `--slide-*` token section (ColaMD 2.7.13 slide layouts) into the generated theme. Presets mirror upstream voices: `serif` (magazine default), `sans` (Notion-like), `mono` (Writer-like); only the brand layer is derived (title font / mono font / title weight, CJK fallback ensured) while the layout size ladder stays at upstream defaults
40
+ - **Auto‑detect** — `extract` command automatically routes to the right extractor (local HTML, URL, DOCX, PDF)
41
+ - **PPT styling (`--ppt`, v0.6.0+, optional)** — extraction can also emit the `--slide-*` token section (ColaMD 2.7.13 slide layouts) into the generated theme. Presets mirror upstream voices: `serif` (magazine default), `sans` (Notion-like), `mono` (Writer-like). Since v0.6.1, `from-html` auto-detects the preset from the template's display font and, when the source provides design hints, derives a **full per-layout token set** (24 tokens): cover/section/closing title ladder from the template's own type scale, page title / KPI / quote / kicker / chrome / page padding tuned by mood (bold/quiet/tech), density, formality and scheme. Themes without design hints keep the brand-voice-only output
41
42
 
42
43
  ### Markdown → PPT Markdown (v0.6.0+)
43
44
 
@@ -48,7 +49,7 @@ After installation, open a `.md` file and run **ColaView MD: Show Preview** from
48
49
  ### HTML / PDF Export
49
50
 
50
51
  - **`export-html`** — render Markdown to a standalone HTML document with theme CSS embedded, Mermaid diagrams and KaTeX math fully rendered
51
- - **`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
52
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)
53
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
54
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.
@@ -220,11 +221,27 @@ cthemes from-docx report.docx --name corporate-theme
220
221
  cthemes from-pdf paper.pdf --name academic-theme
221
222
  ```
222
223
 
224
+ ### Extract from a local HTML template (v0.6.1+)
225
+
226
+ ```bash
227
+ # A sibling template.json (name/tagline/typography/scheme/mood) is used when present
228
+ cthemes from-html templates/vellum/template.html -n vellum --ppt -o themes/vellum.css
229
+
230
+ # Batch: extract every template in a directory (--ppt with no value trusts the
231
+ # preset auto-detected from each template's display font)
232
+ Get-ChildItem templates -Directory | ForEach-Object {
233
+ cthemes from-html "$($_.FullName)\template.html" -n $_.Name --ppt -o "themes/$($_.Name).css"
234
+ }
235
+ ```
236
+
223
237
  ### Extract with PPT slide styling (optional, off by default)
224
238
 
225
239
  ```bash
226
240
  # Also emit --slide-* tokens with the sans preset (serif | sans | mono)
227
241
  cthemes from-url "https://example.com" --name my-brand --ppt sans
242
+
243
+ # --ppt with no preset: keep the extractor's auto-detected preset (from-html templates)
244
+ cthemes from-html template.html --ppt
228
245
  ```
229
246
 
230
247
  ### Convert Markdown into slide-deck Markdown
@@ -318,12 +335,14 @@ cthemes set-theme my-brand --remove
318
335
  |---------|-------------|
319
336
  | `from-url <url>` | Extract theme from a web page URL |
320
337
  | `from-docx <file>` | Extract theme from a .docx document |
338
+ | `from-html <file>` | Extract theme from a local HTML file (sibling `template.json` used as metadata when present) |
321
339
  | `from-pdf <file>` | Extract theme from a PDF document |
322
- | `extract <source>` | Auto-detect source type and extract theme |
340
+ | `extract <source>` | Auto-detect source type (local HTML / URL / .docx / .pdf) and extract theme |
323
341
  | `to-slides <input>` | Convert a Markdown document into slide-deck Markdown (auto-inferred layouts) |
324
342
  | `color-systems` | List 15 built-in color systems |
325
343
  | `list` | List all generated themes |
326
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 |
327
346
  | `set-theme <name>` | Set, register, or remove export themes |
328
347
  | `export-html <input>` | Export Markdown → standalone HTML |
329
348
  | `export-pdf <input>` | Export Markdown → PDF |
@@ -338,7 +357,7 @@ cthemes set-theme my-brand --remove
338
357
  | `-d, --themes-dir` | Themes directory (default: `themes/`) |
339
358
  | `-c, --color-system` | Force a color system |
340
359
  | `-A, --auto-match` | Auto-match a color system from the extracted palette |
341
- | `--ppt [style]` | Also emit PPT `--slide-*` tokens (2.7.13 slides); optional preset `serif` (default) / `sans` / `mono`. Off by default |
360
+ | `--ppt [style]` | Also emit PPT `--slide-*` tokens (2.7.13 slides); optional preset `serif` (default) / `sans` / `mono`. Off by default. A valueless `--ppt` keeps the preset auto-detected by the extractor (from-html templates) |
342
361
 
343
362
  ### to-slides options
344
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytechain.cn/colamd-themes",
3
- "version": "0.6.0",
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",
@@ -14,11 +14,21 @@ Generate, validate, export, and manage ColaMD **2.7 contract** CSS themes (2.7.1
14
14
 
15
15
  ```bash
16
16
  colamd-themes from-url <URL> [options]
17
+ colamd-themes from-html <file> [options]
17
18
  colamd-themes from-docx <file> [options]
18
19
  colamd-themes from-pdf <file> [options]
19
20
  colamd-themes extract <source> [options]
20
21
  ```
21
22
 
23
+ `from-html` extracts from a **local HTML file** (v0.6.1+). A sibling
24
+ `template.json` — when present — supplies authoritative metadata: slug/tagline
25
+ as theme name/description, `typography.display/body/mono` (+ `serif_cn` /
26
+ `sans_cn`) as CJK-safe font stacks, `scheme`/`density`/`formality`/`mood` as
27
+ slide design hints. Colors come from the template's `:root` custom properties
28
+ (semantic-name matching first, luminance/saturation heuristics as fallback);
29
+ the palette is sanitized to satisfy the paradigm's luminance ordering (SL-04)
30
+ and contrast rules (CR-02). `extract` auto-detects local `.html/.htm` too.
31
+
22
32
  ### Export to HTML / PDF
23
33
 
24
34
  ```bash
@@ -49,6 +59,7 @@ colamd-themes set-theme <name> --remove
49
59
  colamd-themes color-systems [-j]
50
60
  colamd-themes list [-d <dir>]
51
61
  colamd-themes validate <file.css | file.md>
62
+ colamd-themes check-pdf <file.pdf> [-d <deck.md>]
52
63
  ```
53
64
 
54
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`.
@@ -64,7 +75,7 @@ colamd-themes validate <file.css | file.md>
64
75
  | `-d, --themes-dir` | Themes directory (default: `themes/`) |
65
76
  | `-c, --color-system` | Force a color system |
66
77
  | `-A, --auto-match` | Auto-match a color system from the extracted palette |
67
- | `--ppt [style]` | Also emit PPT `--slide-*` tokens (2.7.13 slides); optional preset `serif` (default) / `sans` / `mono`. Off by default |
78
+ | `--ppt [style]` | Also emit PPT `--slide-*` tokens (2.7.13 slides); optional preset `serif` (default) / `sans` / `mono`. Off by default. A valueless `--ppt` keeps the preset auto-detected by the extractor (from-html templates) |
68
79
 
69
80
  ### Export options
70
81
 
@@ -213,6 +224,31 @@ colamd-themes validate deck.md
213
224
  - **SLIDES-04/05** (MUST_NOT):页头块字段键 ∉ kicker/label/chapter、deck 键 ∉ logo/brand/title/meta
214
225
  - **SLIDES-06** (MUST_NOT):slide-css 含 `position: absolute/fixed`、`z-index`、伪协议 URL
215
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
+
216
252
  ### PPT style tokens (--slide-*)
217
253
 
218
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:
@@ -222,6 +258,7 @@ colamd-themes from-url <URL> -n my-brand --ppt sans # presets: serif | sans |
222
258
  ```
223
259
 
224
260
  - serif = 上游杂志衬线默认;sans = Notion 气质(无衬线、居中封面);mono = Writer 气质(等宽标题)。品牌层只派生 `--slide-title-font` / `--slide-mono` / `--slide-title-weight`,版式字号阶梯保持上游默认。
261
+ - **v0.6.1 全量版式令牌**:`from-html` 模板来源提供设计提示(`--sz-*` 字号阶梯 + template.json 的 mood/density/formality/scheme)时,生成 **24 个按页类型定制的令牌**——封面/章节/收页字号阶梯取自模板 display/body 比例,页标题 / KPI / 引言 / kicker / chrome / 页边距按气质(bold/quiet/tech)与密度调校;`--ppt` 不带值时信任按 display 字体自动判定的预设。无设计提示的主题保持仅品牌层输出(向后兼容)。
225
262
  - 自定义主题 CSS 在 slides.css 之后加载,`:root` 同权重后到先赢;不要写 `body.theme-custom`(文档契约死选择器)。
226
263
  - 手写主题里的幻灯片规则须遵守:**SLIDE-01** (SHOULD) 只用已知令牌;**SLIDE-02** (MUST_NOT) `.cm-md-page-*` / `.cm-md-slide-*` / `.slide-chrome|foot|ghost` 必须包裹在 `body.presenting` 或 `body.slides-printing` 作用域下(裸写污染编辑视图);**SLIDE-03** (SHOULD) 标题字体栈含中文字族并以 generic family 结尾。
227
264
  - 平台需 ≥ 2.7.13 才消费这些令牌(compat 行「幻灯片版式」);旧平台下令牌惰性。导出的 HTML/PDF 仍为文档式排版,放映版式在 ColaMD 应用内查看。
@@ -239,6 +276,52 @@ colamd-themes from-url <URL> -n my-brand --ppt sans # presets: serif | sans |
239
276
  - Generated CSS ≤ 300 lines
240
277
  - Font stacks must include CJK fallback and end with generic family
241
278
 
279
+ ## Reference-Template Refinement (page-by-page replication)
280
+
281
+ Use when the task is to reproduce a multi-page PPT template
282
+ (`beautiful-html-templates/templates/<slug>/template.html`) as a ColaMD 2.7.13
283
+ slide theme (`themes/<slug>.css`) with strict fidelity. Full methodology:
284
+ `docs/slide-theme-replication.md`. Reference themes: `themes/biennale-yellow.css`
285
+ (header / token / section-1.6 structure) and `themes/pin-and-paper.css`
286
+ (page-background layer chain).
287
+
288
+ ### Workflow
289
+
290
+ 1. **Read the template**: `:root` palette + fonts, then every page section's
291
+ background / title / subtitle / body / object box (padding, radius, shadow).
292
+ 2. **Map pages to layouts**: cover / section / agenda / kpi / timeline / steps /
293
+ matrix / two-col / figure / quote / closing. A mapping supplied by the user
294
+ always wins over your own inference; record it in the file header and §1.5.
295
+ 3. **Convert**: 26px per em (presenting base `clamp(17px,1.35vw,26px)` @1920×1080);
296
+ template px ÷ 26, taking clamp() landing points at 1920. For inline children,
297
+ fix the li base size first, then divide by that scale.
298
+ 4. **Write**: §1.5 `--slide-*` tokens (formula in every comment) → §1.6 scoped
299
+ per-layout rules (composite selectors, SLIDE-02 scopes) → §2/§3 mirrored
300
+ editor/export rules → §4 print.
301
+ 5. **Validate**: `npx tsx src/cli.ts validate themes/<slug>.css` must report
302
+ contract pass + slide-layout support + zero SLIDE- / SLIDES- / CSS-03
303
+ findings. Paradigm errors are allowed only for identity items documented in
304
+ the file header.
305
+
306
+ ### Fidelity checklist (walk every page)
307
+
308
+ - **Background**: swapped-background pages need the full 5-layer chain; ordinary
309
+ pages must not paint a page-level background.
310
+ - **Title**: family / weight / size / line-height / tracking / color / alignment /
311
+ max-width.
312
+ - **Subtitle & kicker**: size, tracking, transform, opacity.
313
+ - **Body**: li base scale + `.cm-md-strong` row title + `.cm-md-listmark`
314
+ number/date; redraw card borders instead of keeping capsule defaults.
315
+ - **Position**: page-level vertical centering, page padding, object-box width
316
+ (border-box, padding included), inter-row gaps.
317
+
318
+ ### Batch runs
319
+
320
+ One theme = one file, so templates can be dispatched in parallel (max 5
321
+ concurrent sub-agents). After each batch verify the file's size/mtime actually
322
+ changed — an unchanged file means a lost run, so re-dispatch it. Run `validate`
323
+ once over every theme at the end.
324
+
242
325
  ## CSS Pitfall Quick Reference
243
326
 
244
327
  > When adjusting themes, follow these rules strictly. Reference `themes/template.css` and the upstream examples in `ColaMD-extend/resources/templates/themes/`.
@@ -267,6 +350,34 @@ colamd-themes from-url <URL> -n my-brand --ppt sans # presets: serif | sans |
267
350
 
268
351
  **Pitfall:** Writing `themeVariables` or Mermaid `classDef` in the theme. **Correct:** override `--pele-*` on `:root`; the SVG reads them at render time.
269
352
 
353
+ ### 7. Layout class and line-role class share one div
354
+
355
+ **Pitfall:** `.cm-md-slide-quote .cm-md-blockquote` (descendant form). **Correct:** `.cm-md-slide-quote.cm-md-blockquote` — the layout class is a line decoration stamped on the same div, so upstream descendant selectors miss in the editor DOM.
356
+
357
+ ### 8. Page-level vertical centering
358
+
359
+ **Pitfall:** The template centers every page (`.slide` = flex column + `justify-content:center`), while upstream only centers cover / section / closing / two-col. **Correct:** single-column layouts get `display:flex; flex-direction:column; justify-content:safe center; min-height:92vh`. Card grids (kpi / matrix / steps / timeline) must keep inline-block flow, so use `flex-wrap:wrap` + `align-content:safe center`, cards `flex:0 0 auto`, every other line `flex:0 0 100%`; also `display:none` the page directive and zero the first line's top padding.
360
+
361
+ ### 9. Per-item color rotation
362
+
363
+ **Pitfall:** Painting every card with the first card's color. **Correct:** target index N with `:nth-child(2 of .cm-md-slide-kpi.cm-md-li) .cm-md-strong` (Chrome 111+); older engines fall back to the base color.
364
+
365
+ ### 10. No commas inside `:nth-child(... of ...)`
366
+
367
+ **Pitfall:** `:nth-child(1 of A, B)` — the validator splits the selector at the comma and flags the second half as unscoped (SLIDE-02). **Correct:** one selector per rule, e.g. `:nth-child(1 of .cm-md-slide-section.cm-md-li)`.
368
+
369
+ ### 11. Object-box width is border-box
370
+
371
+ **Pitfall:** A template `max-width:750px` already includes its 56px padding; drawing the rows at `max-width:866px` makes the box 116px too wide. **Correct:** keep the template's outer width and subtract padding from the content width — never add.
372
+
373
+ ### 12. Upstream `.cm-md-li` margins
374
+
375
+ **Pitfall:** Adding `padding-block` for list gaps while upstream keeps `margin:0.45em 0` turns an 18px gap into 29px. **Correct:** zero `margin-block` first; detect first/last rows with `:has(~ .cm-md-slide-x.cm-md-li)` (not `+`) so blank lines do not break detection.
376
+
377
+ ### 13. Verify before inventing
378
+
379
+ **Pitfall:** Assuming a decorative or motion layer exists on a page. **Correct:** full-text search the template first; when it is absent, say so in the header's "not replicated" note instead of inventing a layout.
380
+
270
381
  ## Architecture
271
382
 
272
383
  ```