@bytechain.cn/colamd-themes 0.3.0 → 0.3.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/.openclaw/skills/colamd-themes/SKILL.md +15 -124
  2. package/.trae/rules/colamd-themes.md +15 -124
  3. package/CHANGELOG.md +142 -3
  4. package/README.md +12 -1
  5. package/README_CN.md +12 -1
  6. package/RELEASENOTE.md +212 -0
  7. package/dist/cli.js +278 -2
  8. package/dist/cli.js.map +1 -1
  9. package/dist/export-cli.d.ts +1 -0
  10. package/dist/export-cli.js +208 -176
  11. package/dist/export-cli.js.map +1 -1
  12. package/dist/extractors/url-extractor.d.ts +6 -0
  13. package/dist/extractors/url-extractor.js +51 -2
  14. package/dist/extractors/url-extractor.js.map +1 -1
  15. package/dist/generator.d.ts +4 -0
  16. package/dist/generator.js +74 -7
  17. package/dist/generator.js.map +1 -1
  18. package/dist/renderer.d.ts +1 -1
  19. package/dist/renderer.js +87 -14
  20. package/dist/renderer.js.map +1 -1
  21. package/dist/theme-store.d.ts +7 -6
  22. package/dist/theme-store.js +84 -34
  23. package/dist/theme-store.js.map +1 -1
  24. package/dist/utils/cli-utils.d.ts +55 -0
  25. package/dist/utils/cli-utils.js +80 -0
  26. package/dist/utils/cli-utils.js.map +1 -0
  27. package/package.json +1 -1
  28. package/skills/colamd-themes/SKILL.md +30 -0
  29. package/src/cli.ts +289 -2
  30. package/src/export-cli.ts +248 -193
  31. package/src/extractors/url-extractor.ts +56 -2
  32. package/src/generator.ts +88 -7
  33. package/src/renderer.ts +96 -14
  34. package/src/theme-store.ts +93 -35
  35. package/src/utils/cli-utils.ts +84 -0
  36. package/.claude/skills/colamd-themes-preview.skill.md +0 -333
  37. package/.claude/skills/colamd-themes.skill.md +0 -155
  38. package/.hermes/skills/tools/colamd-themes/SKILL.md +0 -159
  39. package/.opencode/skills/colamd-themes/SKILL.md +0 -162
@@ -1,333 +0,0 @@
1
- ---
2
- name: colamd-themes-preview
3
- description: >-
4
- Preview and showcase ColaMD themes with interactive HTML demos, batch
5
- comparisons, and development server. Use when user wants to visualize a
6
- theme's appearance across different Markdown elements or compare multiple
7
- themes side-by-side.
8
- ---
9
-
10
- # ColaMD Themes Preview — Visual Theme Showcase
11
-
12
- ## Overview
13
-
14
- This skill complements `colamd-themes` by adding visual preview capabilities:
15
-
16
- - **Static HTML preview** — Generate a standalone HTML file showcasing a theme
17
- - **Batch comparison** — Compare multiple themes in one page with synchronized scrolling
18
- - **Dev server** — Hot-reload preview server for theme development
19
- - **Demo content** — Includes comprehensive Markdown examples (headings, lists, tables, code blocks, Mermaid diagrams, math, etc.)
20
-
21
- ## When to Use
22
-
23
- - After generating a theme with `colamd-themes extract` → preview it before validation
24
- - When choosing between multiple extracted themes → batch compare
25
- - During theme fine-tuning → use dev server for instant feedback
26
- - Before sharing a theme → generate polished showcase page
27
-
28
- ## Prerequisites
29
-
30
- - Node.js ≥ 18
31
- - ColaMD-themes project at: `/Volumes/DATA/data/develop/git/ColaMD-themes`
32
- - Theme CSS files available in `themes/` directory
33
-
34
- ## Commands
35
-
36
- ### Generate Static Preview for a Single Theme
37
-
38
- ```bash
39
- colamd-themes-preview generate <theme.css> [options]
40
- # Output: themes-preview/<theme-name>-preview.html
41
- ```
42
-
43
- Options:
44
-
45
- | Flag | Description |
46
- |------|-------------|
47
- | `-c, --content <file.md>` | Custom Markdown content (default: built-in demo) |
48
- | `-o, --output <path>` | Output HTML file path |
49
- | `-t, --title <text>` | Page title |
50
- | `--embedded` | Embed theme CSS directly (single file) |
51
- | `--no-mermaid` | Skip Mermaid demo section |
52
-
53
- ### Batch Compare Multiple Themes
54
-
55
- ```bash
56
- colamd-themes-preview compare <theme1.css> <theme2.css> [theme3.css...] [options]
57
- # Output: themes-preview/comparison-<timestamp>.html
58
- ```
59
-
60
- Features:
61
- - Themes displayed in vertical tabs
62
- - Synchronized scroll position
63
- - Common content rendered under each theme
64
- - Visual diff indicators (color swatches)
65
-
66
- ### Start Development Preview Server
67
-
68
- ```bash
69
- colamd-themes-preview serve [options]
70
- # Serves at http://localhost:3000
71
- ```
72
-
73
- Options:
74
-
75
- | Flag | Description |
76
- |------|-------------|
77
- | `-p, --port <number>` | Server port (default: 3000) |
78
- | `-w, --watch <dir>` | Watch directory for CSS changes |
79
- | `-t, --themes-dir <dir>` | Themes directory (default: `themes/`) |
80
- | `--open` | Open browser automatically |
81
-
82
- Auto-reload: When a watched CSS file changes, the page refreshes automatically.
83
-
84
- ### Export Demo Content
85
-
86
- ```bash
87
- colamd-themes-preview export-demo <output.md>
88
- # Generates comprehensive Markdown with all element types
89
- ```
90
-
91
- ### Audit Theme against Document Type
92
-
93
- ```bash
94
- colamd-themes-preview audit <theme.css> [options]
95
- ```
96
-
97
- Performs a comprehensive audit of the generated CSS against type-specific design constraints and prints a compliance score.
98
-
99
- Options:
100
-
101
- | Flag | Description |
102
- |------|-------------|
103
- | `-t, --type <type>` | Document type: `document` (meeting minutes, reports), `design` (web page conversions), `ppt` (PDF from slides) |
104
- | `-s, --source <file>` | Source file (DOCX/PDF) to compare against (used for PPT type) |
105
- | `-f, --format <fmt>` | Report format: `text` (default), `json`, `html` |
106
- | `--strict` | Exit with non-zero code on ANY violation (default: only MUST/MUST_NOT failures) |
107
-
108
- The audit checks:
109
-
110
- - Color values against type expectations
111
- - Font stacks for appropriateness
112
- - Mermaid preset suitability
113
- - Print styles synchronization (critical for PPT and document types)
114
- - Contrast ratios and accessibility
115
- - Conformance to v3.0 paradigm rules
116
-
117
- Output includes overall score (0–100) and categorized issues (CRITICAL, WARNING, INFO).
118
-
119
- Example:
120
-
121
- ```
122
- Audit: meeting-minutes.css (type: document)
123
- Overall score: 92/100
124
-
125
- CRITICAL:
126
- (none)
127
-
128
- WARNINGS:
129
- - Accent saturation 0.72 exceeds document-type max 0.6
130
- - Consider a more muted blue for formal documents
131
-
132
- INFO:
133
- - Mermaid preset: light (recommended)
134
- - Font stack includes CJK fallbacks: Yes
135
- ```
136
-
137
- ## Built-in Demo Content
138
-
139
- The preview includes this sample Markdown structure:
140
-
141
- ```
142
- # Heading 1
143
- ## Heading 2
144
- ### Heading 3
145
-
146
- Paragraph with **bold**, *italic*, `inline code`, [links](https://example.com), and ~~strikethrough~~.
147
-
148
- > Blockquote with *emphasized* text and a link.
149
-
150
- - Unordered list item 1
151
- - Unordered list item 2
152
- - Nested item
153
- - Another nested item
154
-
155
- 1. Ordered list item 1
156
- 2. Ordered list item 2
157
- 1. Nested ordered item
158
-
159
- - [ ] Task list item (unchecked)
160
- - [x] Task list item (checked)
161
-
162
- ```python
163
- def hello():
164
- print("Hello, ColaMD!")
165
- ```
166
-
167
- | Header 1 | Header 2 | Header 3 |
168
- |----------|----------|----------|
169
- | Cell 1 | Cell 2 | Cell 3 |
170
- | Cell 4 | Cell 5 | Cell 6 |
171
-
172
- ---
173
-
174
- ```mermaid
175
- graph TD
176
- A[Start] --> B{Decision}
177
- B --> C[Option 1]
178
- B --> D[Option 2]
179
- ```
180
-
181
- $$
182
- \int_{a}^{b} x^2 dx
183
- $$
184
-
185
- ---
186
-
187
- [[toc]]
188
- ```
189
-
190
- ## HTML Preview Features
191
-
192
- Generated preview pages include:
193
-
194
- 1. **Theme metadata bar** — name, color system, mermaid preset
195
- 2. **Color palette swatches** — seed colors displayed as swatches
196
- 3. **Typography samples** — heading and body font renders
197
- 4. **Full Markdown rendering** — all ColaMD-supported elements
198
- 5. **Print preview toggle** — switch to print stylesheet view
199
- 6. **Mobile responsive toggle** — simulate mobile viewport
200
- 7. **CSS source viewer** — collapsible panel to inspect the theme file
201
- 8. **Download button** — export the theme CSS
202
-
203
- ## Batch Comparison Layout
204
-
205
- Comparison page organizes themes horizontally (if < 4 themes) or in tabs:
206
-
207
- - **Color palette matrix** — side-by-side swatch comparison
208
- - **Shared scroll container** — all themes scroll together
209
- - **Highlight differences** — hover a theme to emphasize it
210
- - **Export all** — zip all themes + preview HTML
211
-
212
- ## Development Server Workflow
213
-
214
- ```bash
215
- # Start server with watch
216
- colamd-themes-preview serve -w themes/
217
-
218
- # In another terminal, edit your theme CSS
219
- # Browser auto-refreshes on save
220
- ```
221
-
222
- The server serves:
223
- - `/` — theme selector + preview
224
- - `/preview/<theme-name>` — single theme preview
225
- - `/compare` — batch comparison (query: ?themes=a.css,b.css)
226
- - `/demo-content.md` — raw demo content
227
-
228
- ## Integration with colamd-themes
229
-
230
- Typical workflow:
231
-
232
- 1. Extract theme:
233
- ```bash
234
- colamd-themes extract source.docx --name my-theme --auto-match
235
- ```
236
-
237
- 2. Preview it:
238
- ```bash
239
- colamd-themes-preview generate themes/my-theme.css --embedded
240
- ```
241
-
242
- 3. Fine-tune seed colors manually in `themes/my-theme.css` (SECTION 1 only)
243
-
244
- 4. Re-preview instantly with dev server:
245
- ```bash
246
- colamd-themes-preview serve -w themes/
247
- ```
248
-
249
- 5. Validate:
250
- ```bash
251
- colamd-themes validate themes/my-theme.css
252
- ```
253
-
254
- 6. (Optional) Compare with alternatives:
255
- ```bash
256
- colamd-themes-preview compare themes/*.css
257
- ```
258
-
259
- 7. Audit against document type expectations:
260
- ```bash
261
- colamd-themes-preview audit themes/my-theme.css --type document
262
- ```
263
-
264
- ## Code Audit Rules
265
-
266
- The `audit` command validates a theme against expectations for its document type. Rules are prioritized:
267
-
268
- - **MUST** / **MUST_NOT** — critical non-negotiable constraints (fail audit)
269
- - **SHOULD** / **SHOULD_NOT** — recommended best practices (warnings)
270
- - **INFO** — informational notes (no score impact)
271
-
272
- ### Document Type Rules
273
-
274
- **Document** (meeting minutes, reports, proposals):
275
-
276
- - Surface: near-white (Luminance ≥ 0.95)
277
- - Ink: dark (Luminance ≤ 0.2 or hex `#000000`–`#222222`)
278
- - Accent: medium saturation (0.3 ≤ S ≤ 0.6), professional hues (blue, teal, burgundy)
279
- - Mermaid preset: `light`
280
- - Font bodies: serif or clean sans-serif, include CJK fallbacks
281
- - Print styles: MUST match screen colors exactly; `@media print` block must re-declare `--seed-accent` and `--seed-accent-dark` to the same hex values as screen
282
- - Expectation: readability, print-friendliness, conservative palette
283
-
284
- **Design** (web page style conversions):
285
-
286
- - Surface: varies (light or dark)
287
- - Accent: high saturation (S ≥ 0.6), vibrant colors, possible gradients
288
- - Font families: modern sans-serif stack, may include display fonts
289
- - Mermaid preset: auto-detected based on background luminance
290
- - Print styles: SHOULD preserve brand colors; if source has print styles, compare against them
291
- - Expectation: faithful reproduction of source website's visual identity
292
-
293
- **PPT** (PDF from presentation slides):
294
-
295
- - Must preserve original slide color scheme (extracted from source PDF)
296
- - Text colors must match original slide text colors within tolerance
297
- - Mermaid colors should follow slide accent palette
298
- - Font choices should reflect slide typography
299
- - Print styles: CRITICAL — print MUST match slide design exactly; verify `@media print` exists and re-declares all seed colors correctly (especially accent)
300
- - Expectation: high fidelity to original slide design, including print output
301
-
302
- ## Implementation Notes
303
-
304
- - Preview HTML uses a simple client-side renderer (marked.js or similar)
305
- - No additional build step required — copies template + injects theme CSS
306
- - Embedded mode inlines the entire CSS to avoid CORS issues when sharing
307
- - Dev server uses `chokidar` for file watching and `ws` for live reload WebSocket
308
-
309
- ## File Structure
310
-
311
- ```
312
- ColaMD-themes/
313
- ├── .claude/skills/
314
- │ ├── colamd-themes.skill.md (existing)
315
- │ └── colamd-themes-preview.skill.md (this skill)
316
- ├── src/
317
- │ ├── preview/
318
- │ │ ├── preview-server.ts (dev server)
319
- │ │ ├── generate-html.ts (static HTML generator)
320
- │ │ ├── demo-content.md (built-in Markdown sample)
321
- │ │ └── template.html (HTML skeleton)
322
- │ └── cli.ts (+ new subcommands)
323
- ├── themes-preview/ (output directory)
324
- └── package.json (adds preview deps)
325
- ```
326
-
327
- ## Future Enhancements
328
-
329
- - Screenshot automation (puppeteer) for documentation
330
- - Export to PDF with print styles applied
331
- - Share to ColaMD community gallery
332
- - AI-driven theme critique (color harmony, contrast feedback)
333
- - Theme package (.zip) with preview, demo, and license
@@ -1,155 +0,0 @@
1
- ---
2
- name: colamd-themes
3
- description: >
4
- Generate, validate, export, and manage ColaMD v3.0 paradigm CSS themes.
5
- Extract formatting from URLs, DOCX, or PDF sources; export Markdown to
6
- standalone HTML/PDF with themes applied; batch export; manage theme
7
- configuration.
8
- ---
9
-
10
- Generate, validate, export, and manage ColaMD v3.0 paradigm CSS themes. Extract formatting from URLs, DOCX, or PDF sources; export Markdown to standalone HTML/PDF with themes applied; batch export; manage theme configuration.
11
-
12
- ## Prerequisites
13
-
14
- - Node.js ≥ 18
15
- - Project root: run `npm install && npm run build` before first use
16
- - Or run directly: `npx tsx src/cli.ts <command>`
17
-
18
- ## Commands
19
-
20
- ### Theme extraction
21
-
22
- ```bash
23
- colamd-themes from-url <URL> [options]
24
- colamd-themes from-docx <file> [options]
25
- colamd-themes from-pdf <file> [options]
26
- colamd-themes extract <source> [options]
27
- ```
28
-
29
- ### Export to HTML / PDF
30
-
31
- ```bash
32
- colamd-themes export-html <input.md> -t <theme> -o <output.html>
33
- colamd-themes export-pdf <input.md> -t <theme> -o <output.pdf>
34
- colamd-themes export <inputs...> --format html|pdf -t <theme> -d <dir>
35
- ```
36
-
37
- ### Theme management
38
-
39
- ```bash
40
- colamd-themes set-theme <name> --default
41
- colamd-themes set-theme <name> --css <file>
42
- colamd-themes set-theme <name> --css <file> --default
43
- colamd-themes set-theme <name> --remove
44
- ```
45
-
46
- ### Inspection
47
-
48
- ```bash
49
- colamd-themes color-systems [-j]
50
- colamd-themes mermaid-presets [-j]
51
- colamd-themes list [-d <dir>]
52
- colamd-themes validate <file.css>
53
- ```
54
-
55
- ## Options
56
-
57
- ### Extract options
58
-
59
- | Flag | Description |
60
- |------|-------------|
61
- | `-n, --name` | Theme name |
62
- | `-o, --output` | Output CSS file path |
63
- | `-d, --themes-dir` | Themes directory (default: `themes/`) |
64
- | `-c, --color-system` | Force a color system |
65
- | `-m, --mermaid-preset` | Force a Mermaid preset (light/dark/elegant) |
66
- | `-A, --auto-match` | Auto-match color system and Mermaid preset |
67
-
68
- ### Export options
69
-
70
- | Flag | Description |
71
- |------|-------------|
72
- | `-t, --theme` | Theme: built-in name, custom name, or `.css` file path |
73
- | `-o, --output` | Output file path |
74
- | `-d, --output-dir` | Output directory for batch export |
75
- | `--format` | Batch: `html` or `pdf`; PDF: `A4`, `Letter`, `A3` |
76
-
77
- ## Theme Resolution
78
-
79
- `-t, --theme` accepts:
80
- 1. **Built-in**: `light`, `dark`, `elegant`, `newsprint`
81
- 2. **Custom registered**: name set via `set-theme --css`
82
- 3. **File path**: any `.css` file on disk
83
-
84
- Config: `~/.colamd-themes/config.json`
85
-
86
- ## Color Systems (15 schemes)
87
-
88
- | Family | Schemes |
89
- |--------|---------|
90
- | 莫兰迪 (Morandi) | misty-rose, sage-green, dusky-blue |
91
- | 马卡龙 (Macaron) | strawberry, mint, lavender |
92
- | 北欧 (Nordic) | fjord-blue, pine-green, cloud-grey |
93
- | 复古 (Vintage) | amber, burgundy, forest |
94
- | 薄荷绿 (Mint) | matcha, spearmint, seafoam |
95
-
96
- ## Mermaid Presets
97
-
98
- `light` — cool accent on light bg | `dark` — dark bg | `elegant` — warm accent on light bg
99
-
100
- ## Workflow Examples
101
-
102
- ### Create theme from source
103
-
104
- ```bash
105
- colamd-themes extract <source> --name "my-theme" --auto-match
106
- ```
107
-
108
- ### Export with theme
109
-
110
- ```bash
111
- colamd-themes export-html doc.md -t elegant -o output.html
112
- colamd-themes export-pdf doc.md -t my-brand -o output.pdf
113
- ```
114
-
115
- ### Batch export
116
-
117
- ```bash
118
- colamd-themes export docs/ --format pdf -t dark -d output/
119
- ```
120
-
121
- ### Validate theme
122
-
123
- ```bash
124
- colamd-themes validate themes/my-theme.css
125
- ```
126
-
127
- ## Rendering Pipeline
128
-
129
- Export uses Puppeteer (headless Chromium) with `@bytechain.cn/colamd/renderer`:
130
-
131
- 1. Local HTTP server serves renderer ESM bundle (avoids CORS)
132
- 2. Puppeteer navigates to server page (same-origin)
133
- 3. `createColaMDEditor({ editable: false })` initializes Milkdown editor
134
- 4. `applyTheme(name, customCSS?)` sets theme
135
- 5. `setMarkdown(content)` loads document
136
- 6. `ensureAllPluginsRendered()` waits for mermaid/KaTeX
137
- 7. `buildExportHTML()` → standalone HTML with embedded CSS
138
- 8. For PDF: `emulateMediaType('screen')` + `page.pdf()`
139
-
140
- ## v3.0 Paradigm Constraints
141
-
142
- - No bare hex colors in selectors — use `var(--seed-*)`
143
- - No bare font sizes — use `var(--font-*)`
144
- - No Mermaid SVG selectors (handled by built-in `variables.css`)
145
- - `!important` only in `@media print`
146
- - Generated CSS ≤ 300 lines
147
- - Font stacks must include CJK fallback and end with generic family
148
-
149
- ## Architecture
150
-
151
- ```
152
- Source → Extractor → ThemeStyle → Color System + Mermaid Preset + Validators → CSS
153
-
154
- Markdown → Puppeteer + ColaMD Renderer → HTML / PDF
155
- ```
@@ -1,159 +0,0 @@
1
- ---
2
- name: colamd-themes
3
- description: "Generate, validate, export, and manage ColaMD v3.0 paradigm CSS themes."
4
- version: 1.0.0
5
- author: bytechain
6
- license: MIT
7
- metadata:
8
- hermes:
9
- tags: [colamd, themes, css, markdown, export, pdf, html]
10
- prerequisites:
11
- commands: [node, npm]
12
- ---
13
-
14
- Generate, validate, export, and manage ColaMD v3.0 paradigm CSS themes. Extract formatting from URLs, DOCX, or PDF sources; export Markdown to standalone HTML/PDF with themes applied; batch export; manage theme configuration.
15
-
16
- ## Prerequisites
17
-
18
- - Node.js ≥ 18
19
- - Project root: run `npm install && npm run build` before first use
20
- - Or run directly: `npx tsx src/cli.ts <command>`
21
-
22
- ## Commands
23
-
24
- ### Theme extraction
25
-
26
- ```bash
27
- colamd-themes from-url <URL> [options]
28
- colamd-themes from-docx <file> [options]
29
- colamd-themes from-pdf <file> [options]
30
- colamd-themes extract <source> [options]
31
- ```
32
-
33
- ### Export to HTML / PDF
34
-
35
- ```bash
36
- colamd-themes export-html <input.md> -t <theme> -o <output.html>
37
- colamd-themes export-pdf <input.md> -t <theme> -o <output.pdf>
38
- colamd-themes export <inputs...> --format html|pdf -t <theme> -d <dir>
39
- ```
40
-
41
- ### Theme management
42
-
43
- ```bash
44
- colamd-themes set-theme <name> --default
45
- colamd-themes set-theme <name> --css <file>
46
- colamd-themes set-theme <name> --css <file> --default
47
- colamd-themes set-theme <name> --remove
48
- ```
49
-
50
- ### Inspection
51
-
52
- ```bash
53
- colamd-themes color-systems [-j]
54
- colamd-themes mermaid-presets [-j]
55
- colamd-themes list [-d <dir>]
56
- colamd-themes validate <file.css>
57
- ```
58
-
59
- ## Options
60
-
61
- ### Extract options
62
-
63
- | Flag | Description |
64
- |------|-------------|
65
- | `-n, --name` | Theme name |
66
- | `-o, --output` | Output CSS file path |
67
- | `-d, --themes-dir` | Themes directory (default: `themes/`) |
68
- | `-c, --color-system` | Force a color system |
69
- | `-m, --mermaid-preset` | Force a Mermaid preset (light/dark/elegant) |
70
- | `-A, --auto-match` | Auto-match color system and Mermaid preset |
71
-
72
- ### Export options
73
-
74
- | Flag | Description |
75
- |------|-------------|
76
- | `-t, --theme` | Theme: built-in name, custom name, or `.css` file path |
77
- | `-o, --output` | Output file path |
78
- | `-d, --output-dir` | Output directory for batch export |
79
- | `--format` | Batch: `html` or `pdf`; PDF: `A4`, `Letter`, `A3` |
80
-
81
- ## Theme Resolution
82
-
83
- `-t, --theme` accepts:
84
- 1. **Built-in**: `light`, `dark`, `elegant`, `newsprint`
85
- 2. **Custom registered**: name set via `set-theme --css`
86
- 3. **File path**: any `.css` file on disk
87
-
88
- Config: `~/.colamd-themes/config.json`
89
-
90
- ## Color Systems (15 schemes)
91
-
92
- | Family | Schemes |
93
- |--------|---------|
94
- | 莫兰迪 (Morandi) | misty-rose, sage-green, dusky-blue |
95
- | 马卡龙 (Macaron) | strawberry, mint, lavender |
96
- | 北欧 (Nordic) | fjord-blue, pine-green, cloud-grey |
97
- | 复古 (Vintage) | amber, burgundy, forest |
98
- | 薄荷绿 (Mint) | matcha, spearmint, seafoam |
99
-
100
- ## Mermaid Presets
101
-
102
- `light` — cool accent on light bg | `dark` — dark bg | `elegant` — warm accent on light bg
103
-
104
- ## Workflow Examples
105
-
106
- ### Create theme from source
107
-
108
- ```bash
109
- colamd-themes extract <source> --name "my-theme" --auto-match
110
- ```
111
-
112
- ### Export with theme
113
-
114
- ```bash
115
- colamd-themes export-html doc.md -t elegant -o output.html
116
- colamd-themes export-pdf doc.md -t my-brand -o output.pdf
117
- ```
118
-
119
- ### Batch export
120
-
121
- ```bash
122
- colamd-themes export docs/ --format pdf -t dark -d output/
123
- ```
124
-
125
- ### Validate theme
126
-
127
- ```bash
128
- colamd-themes validate themes/my-theme.css
129
- ```
130
-
131
- ## Rendering Pipeline
132
-
133
- Export uses Puppeteer (headless Chromium) with `@bytechain.cn/colamd/renderer`:
134
-
135
- 1. Local HTTP server serves renderer ESM bundle (avoids CORS)
136
- 2. Puppeteer navigates to server page (same-origin)
137
- 3. `createColaMDEditor({ editable: false })` initializes Milkdown editor
138
- 4. `applyTheme(name, customCSS?)` sets theme
139
- 5. `setMarkdown(content)` loads document
140
- 6. `ensureAllPluginsRendered()` waits for mermaid/KaTeX
141
- 7. `buildExportHTML()` → standalone HTML with embedded CSS
142
- 8. For PDF: `emulateMediaType('screen')` + `page.pdf()`
143
-
144
- ## v3.0 Paradigm Constraints
145
-
146
- - No bare hex colors in selectors — use `var(--seed-*)`
147
- - No bare font sizes — use `var(--font-*)`
148
- - No Mermaid SVG selectors (handled by built-in `variables.css`)
149
- - `!important` only in `@media print`
150
- - Generated CSS ≤ 300 lines
151
- - Font stacks must include CJK fallback and end with generic family
152
-
153
- ## Architecture
154
-
155
- ```
156
- Source → Extractor → ThemeStyle → Color System + Mermaid Preset + Validators → CSS
157
-
158
- Markdown → Puppeteer + ColaMD Renderer → HTML / PDF
159
- ```