@bytechain.cn/colamd-themes 0.3.1 → 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.
@@ -18,144 +18,35 @@ metadata:
18
18
  bins: [node, npm]
19
19
  ---
20
20
 
21
- 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.
21
+ ## CSS Pitfall Quick Reference
22
22
 
23
- ## Prerequisites
23
+ > When adjusting themes, follow these rules strictly. For each step, reference the corresponding pattern in `academic-paper.css`.
24
24
 
25
- - Node.js ≥ 18
26
- - Project root: run `npm install && npm run build` before first use
27
- - Or run directly: `npx tsx src/cli.ts <command>`
25
+ ### 1. Screen & Print Must Stay in Sync
28
26
 
29
- ## Commands
27
+ Every rule in SECTION 5 must have a mirror copy in SECTION 6 `@media print`. Reference the `SECTION 5 / SECTION 6` correspondence in `academic-paper.css`.
30
28
 
31
- ### Theme extraction
29
+ ### 2. Body Text First-Line Indent
32
30
 
33
- ```bash
34
- colamd-themes from-url <URL> [options]
35
- colamd-themes from-docx <file> [options]
36
- colamd-themes from-pdf <file> [options]
37
- colamd-themes extract <source> [options]
38
- ```
39
-
40
- ### Export to HTML / PDF
41
-
42
- ```bash
43
- colamd-themes export-html <input.md> -t <theme> -o <output.html>
44
- colamd-themes export-pdf <input.md> -t <theme> -o <output.pdf>
45
- colamd-themes export <inputs...> --format html|pdf -t <theme> -d <dir>
46
- ```
47
-
48
- ### Theme management
49
-
50
- ```bash
51
- colamd-themes set-theme <name> --default
52
- colamd-themes set-theme <name> --css <file>
53
- colamd-themes set-theme <name> --css <file> --default
54
- colamd-themes set-theme <name> --remove
55
- ```
56
-
57
- ### Inspection
58
-
59
- ```bash
60
- colamd-themes color-systems [-j]
61
- colamd-themes mermaid-presets [-j]
62
- colamd-themes list [-d <dir>]
63
- colamd-themes validate <file.css>
64
- ```
65
-
66
- ## Options
67
-
68
- ### Extract options
69
-
70
- | Flag | Description |
71
- |------|-------------|
72
- | `-n, --name` | Theme name |
73
- | `-o, --output` | Output CSS file path |
74
- | `-d, --themes-dir` | Themes directory (default: `themes/`) |
75
- | `-c, --color-system` | Force a color system |
76
- | `-m, --mermaid-preset` | Force a Mermaid preset (light/dark/elegant) |
77
- | `-A, --auto-match` | Auto-match color system and Mermaid preset |
78
-
79
- ### Export options
80
-
81
- | Flag | Description |
82
- |------|-------------|
83
- | `-t, --theme` | Theme: built-in name, custom name, or `.css` file path |
84
- | `-o, --output` | Output file path |
85
- | `-d, --output-dir` | Output directory for batch export |
86
- | `--format` | Batch: `html` or `pdf`; PDF: `A4`, `Letter`, `A3` |
87
-
88
- ## Theme Resolution
31
+ **Pitfall:** `#write p` does not match. **Correct:** Reference `academic-paper.css` §5.3 directly — use `body.theme-custom p, body.theme-custom #write > p`, with `margin: 0` set beforehand.
89
32
 
90
- `-t, --theme` accepts:
91
- 1. **Built-in**: `light`, `dark`, `elegant`, `newsprint`
92
- 2. **Custom registered**: name set via `set-theme --css`
93
- 3. **File path**: any `.css` file on disk
33
+ ### 3. Indent Exclusion (Do Not Pollute Lists / Tables / Diagrams)
94
34
 
95
- Config: `~/.colamd-themes/config.json`
35
+ **Pitfall:** The `p` selector hits paragraphs inside all nested containers. **Correct:** Reference the exclusion block below `swiss-design.css` §5.2.1 — apply `text-indent: 0` uniformly to `li / li p / td p / th p / blockquote p / .mermaid-block p / figure p / pre p`.
96
36
 
97
- ## Color Systems (15 schemes)
37
+ ### 4. List Indentation (Hardest Pitfall)
98
38
 
99
- | Family | Schemes |
100
- |--------|---------|
101
- | 莫兰迪 (Morandi) | misty-rose, sage-green, dusky-blue |
102
- | 马卡龙 (Macaron) | strawberry, mint, lavender |
103
- | 北欧 (Nordic) | fjord-blue, pine-green, cloud-grey |
104
- | 复古 (Vintage) | amber, burgundy, forest |
105
- | 薄荷绿 (Mint) | matcha, spearmint, seafoam |
106
-
107
- ## Mermaid Presets
108
-
109
- `light` — cool accent on light bg | `dark` — dark bg | `elegant` — warm accent on light bg
110
-
111
- ## Workflow Examples
112
-
113
- ### Create theme from source
114
-
115
- ```bash
116
- colamd-themes extract <source> --name "my-theme" --auto-match
117
- ```
118
-
119
- ### Export with theme
120
-
121
- ```bash
122
- colamd-themes export-html doc.md -t elegant -o output.html
123
- colamd-themes export-pdf doc.md -t my-brand -o output.pdf
124
- ```
125
-
126
- ### Batch export
127
-
128
- ```bash
129
- colamd-themes export docs/ --format pdf -t dark -d output/
130
- ```
131
-
132
- ### Validate theme
133
-
134
- ```bash
135
- colamd-themes validate themes/my-theme.css
136
- ```
39
+ **Pitfall:** `padding-left` does not move the bullet/number; missing the `#editor .ProseMirror` editor selector; missing `li::before` and `li > p` inline conversion.
137
40
 
138
- ## Rendering Pipeline
41
+ **Correct:** Reference `academic-paper.css` §5.7 directly — copy its full selector structure (`#editor .ProseMirror > ul/ol` + `#write > ul/ol:first-of-type` + `li::before` + `#editor .ProseMirror li > p`). Use `margin-left: 2em` for indentation instead of `padding-left`. For Swiss style, keep `list-style-position: outside` and do NOT change to `none`.
139
42
 
140
- Export uses Puppeteer (headless Chromium) with `@bytechain.cn/colamd/renderer`:
43
+ ### 5. Mermaid CJK Text Overflow
141
44
 
142
- 1. Local HTTP server serves renderer ESM bundle (avoids CORS)
143
- 2. Puppeteer navigates to server page (same-origin)
144
- 3. `createColaMDEditor({ editable: false })` initializes Milkdown editor
145
- 4. `applyTheme(name, customCSS?)` sets theme
146
- 5. `setMarkdown(content)` loads document
147
- 6. `ensureAllPluginsRendered()` waits for mermaid/KaTeX
148
- 7. `buildExportHTML()` → standalone HTML with embedded CSS
149
- 8. For PDF: `emulateMediaType('screen')` + `page.pdf()`
45
+ **Pitfall:** Multi-line `<br/>` nodes have incorrect width/height calculations. **Correct:** ≤ 2 lines per node + `fontSize: 14px` + simplify text (use `·` instead of `/`, remove redundant modifiers).
150
46
 
151
- ## v3.0 Paradigm Constraints
47
+ ### 6. Mermaid classDef Does Not Inherit themeVariables
152
48
 
153
- - No bare hex colors in selectors — use `var(--seed-*)`
154
- - No bare font sizes — use `var(--font-*)`
155
- - No Mermaid SVG selectors (handled by built-in `variables.css`)
156
- - `!important` only in `@media print`
157
- - Generated CSS ≤ 300 lines
158
- - Font stacks must include CJK fallback and end with generic family
49
+ **Pitfall:** Assuming `themeVariables` sets text color so you don't need to repeat it. **Correct:** `classDef` must explicitly declare all three properties: `fill / color / stroke`.
159
50
 
160
51
  ## Architecture
161
52
 
@@ -2,144 +2,35 @@
2
2
 
3
3
  When the user asks to create, validate, export, or manage ColaMD themes, use the following CLI tool:
4
4
 
5
- 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.
5
+ ## CSS Pitfall Quick Reference
6
6
 
7
- ## Prerequisites
7
+ > When adjusting themes, follow these rules strictly. For each step, reference the corresponding pattern in `academic-paper.css`.
8
8
 
9
- - Node.js ≥ 18
10
- - Project root: run `npm install && npm run build` before first use
11
- - Or run directly: `npx tsx src/cli.ts <command>`
9
+ ### 1. Screen & Print Must Stay in Sync
12
10
 
13
- ## Commands
11
+ Every rule in SECTION 5 must have a mirror copy in SECTION 6 `@media print`. Reference the `SECTION 5 / SECTION 6` correspondence in `academic-paper.css`.
14
12
 
15
- ### Theme extraction
13
+ ### 2. Body Text First-Line Indent
16
14
 
17
- ```bash
18
- colamd-themes from-url <URL> [options]
19
- colamd-themes from-docx <file> [options]
20
- colamd-themes from-pdf <file> [options]
21
- colamd-themes extract <source> [options]
22
- ```
23
-
24
- ### Export to HTML / PDF
25
-
26
- ```bash
27
- colamd-themes export-html <input.md> -t <theme> -o <output.html>
28
- colamd-themes export-pdf <input.md> -t <theme> -o <output.pdf>
29
- colamd-themes export <inputs...> --format html|pdf -t <theme> -d <dir>
30
- ```
31
-
32
- ### Theme management
33
-
34
- ```bash
35
- colamd-themes set-theme <name> --default
36
- colamd-themes set-theme <name> --css <file>
37
- colamd-themes set-theme <name> --css <file> --default
38
- colamd-themes set-theme <name> --remove
39
- ```
40
-
41
- ### Inspection
42
-
43
- ```bash
44
- colamd-themes color-systems [-j]
45
- colamd-themes mermaid-presets [-j]
46
- colamd-themes list [-d <dir>]
47
- colamd-themes validate <file.css>
48
- ```
49
-
50
- ## Options
51
-
52
- ### Extract options
53
-
54
- | Flag | Description |
55
- |------|-------------|
56
- | `-n, --name` | Theme name |
57
- | `-o, --output` | Output CSS file path |
58
- | `-d, --themes-dir` | Themes directory (default: `themes/`) |
59
- | `-c, --color-system` | Force a color system |
60
- | `-m, --mermaid-preset` | Force a Mermaid preset (light/dark/elegant) |
61
- | `-A, --auto-match` | Auto-match color system and Mermaid preset |
62
-
63
- ### Export options
64
-
65
- | Flag | Description |
66
- |------|-------------|
67
- | `-t, --theme` | Theme: built-in name, custom name, or `.css` file path |
68
- | `-o, --output` | Output file path |
69
- | `-d, --output-dir` | Output directory for batch export |
70
- | `--format` | Batch: `html` or `pdf`; PDF: `A4`, `Letter`, `A3` |
71
-
72
- ## Theme Resolution
15
+ **Pitfall:** `#write p` does not match. **Correct:** Reference `academic-paper.css` §5.3 directly — use `body.theme-custom p, body.theme-custom #write > p`, with `margin: 0` set beforehand.
73
16
 
74
- `-t, --theme` accepts:
75
- 1. **Built-in**: `light`, `dark`, `elegant`, `newsprint`
76
- 2. **Custom registered**: name set via `set-theme --css`
77
- 3. **File path**: any `.css` file on disk
17
+ ### 3. Indent Exclusion (Do Not Pollute Lists / Tables / Diagrams)
78
18
 
79
- Config: `~/.colamd-themes/config.json`
19
+ **Pitfall:** The `p` selector hits paragraphs inside all nested containers. **Correct:** Reference the exclusion block below `swiss-design.css` §5.2.1 — apply `text-indent: 0` uniformly to `li / li p / td p / th p / blockquote p / .mermaid-block p / figure p / pre p`.
80
20
 
81
- ## Color Systems (15 schemes)
21
+ ### 4. List Indentation (Hardest Pitfall)
82
22
 
83
- | Family | Schemes |
84
- |--------|---------|
85
- | 莫兰迪 (Morandi) | misty-rose, sage-green, dusky-blue |
86
- | 马卡龙 (Macaron) | strawberry, mint, lavender |
87
- | 北欧 (Nordic) | fjord-blue, pine-green, cloud-grey |
88
- | 复古 (Vintage) | amber, burgundy, forest |
89
- | 薄荷绿 (Mint) | matcha, spearmint, seafoam |
90
-
91
- ## Mermaid Presets
92
-
93
- `light` — cool accent on light bg | `dark` — dark bg | `elegant` — warm accent on light bg
94
-
95
- ## Workflow Examples
96
-
97
- ### Create theme from source
98
-
99
- ```bash
100
- colamd-themes extract <source> --name "my-theme" --auto-match
101
- ```
102
-
103
- ### Export with theme
104
-
105
- ```bash
106
- colamd-themes export-html doc.md -t elegant -o output.html
107
- colamd-themes export-pdf doc.md -t my-brand -o output.pdf
108
- ```
109
-
110
- ### Batch export
111
-
112
- ```bash
113
- colamd-themes export docs/ --format pdf -t dark -d output/
114
- ```
115
-
116
- ### Validate theme
117
-
118
- ```bash
119
- colamd-themes validate themes/my-theme.css
120
- ```
23
+ **Pitfall:** `padding-left` does not move the bullet/number; missing the `#editor .ProseMirror` editor selector; missing `li::before` and `li > p` inline conversion.
121
24
 
122
- ## Rendering Pipeline
25
+ **Correct:** Reference `academic-paper.css` §5.7 directly — copy its full selector structure (`#editor .ProseMirror > ul/ol` + `#write > ul/ol:first-of-type` + `li::before` + `#editor .ProseMirror li > p`). Use `margin-left: 2em` for indentation instead of `padding-left`. For Swiss style, keep `list-style-position: outside` and do NOT change to `none`.
123
26
 
124
- Export uses Puppeteer (headless Chromium) with `@bytechain.cn/colamd/renderer`:
27
+ ### 5. Mermaid CJK Text Overflow
125
28
 
126
- 1. Local HTTP server serves renderer ESM bundle (avoids CORS)
127
- 2. Puppeteer navigates to server page (same-origin)
128
- 3. `createColaMDEditor({ editable: false })` initializes Milkdown editor
129
- 4. `applyTheme(name, customCSS?)` sets theme
130
- 5. `setMarkdown(content)` loads document
131
- 6. `ensureAllPluginsRendered()` waits for mermaid/KaTeX
132
- 7. `buildExportHTML()` → standalone HTML with embedded CSS
133
- 8. For PDF: `emulateMediaType('screen')` + `page.pdf()`
29
+ **Pitfall:** Multi-line `<br/>` nodes have incorrect width/height calculations. **Correct:** ≤ 2 lines per node + `fontSize: 14px` + simplify text (use `·` instead of `/`, remove redundant modifiers).
134
30
 
135
- ## v3.0 Paradigm Constraints
31
+ ### 6. Mermaid classDef Does Not Inherit themeVariables
136
32
 
137
- - No bare hex colors in selectors — use `var(--seed-*)`
138
- - No bare font sizes — use `var(--font-*)`
139
- - No Mermaid SVG selectors (handled by built-in `variables.css`)
140
- - `!important` only in `@media print`
141
- - Generated CSS ≤ 300 lines
142
- - Font stacks must include CJK fallback and end with generic family
33
+ **Pitfall:** Assuming `themeVariables` sets text color so you don't need to repeat it. **Correct:** `classDef` must explicitly declare all three properties: `fill / color / stroke`.
143
34
 
144
35
  ## Architecture
145
36
 
package/CHANGELOG.md CHANGED
@@ -5,14 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
8
+ ## [0.3.2] - 2026-05-29
9
9
 
10
10
  ### Added
11
+ - **CSS Pitfall Quick Reference**: Comprehensive 6-topic guide for theme authoring in AI agent skills, covering screen/print sync, body text indent, indent exclusion, list indentation, Mermaid CJK text overflow, and Mermaid classDef inheritance rules
11
12
  - New theme: **Trae Blue** — modern blue-themed design for technical documentation
12
13
  - New theme: **Forest Ink** — nature-inspired dark green palette with ink aesthetics
13
14
  - Support for absolute path input in CLI commands
14
15
  - Two new theme preview HTML files (colly-preview, salvator-blog-preview)
15
- - CSS pitfall reference documentation
16
16
  - Short CLI alias `cthemes` as alternative to `colamd-themes`
17
17
  - Unified error handling system with structured error codes (`CLIError` + `ErrorCode`)
18
18
  - Shared utility functions for consistent file path resolution (`cli-utils.ts`)
@@ -233,7 +233,8 @@ User Input → Validation Layer → Processing Layer
233
233
 
234
234
  ---
235
235
 
236
- [Unreleased]: https://github.com/byteuser1977/ColaMD-themes/compare/v0.3.1...HEAD
236
+ [Unreleased]: https://github.com/byteuser1977/ColaMD-themes/compare/v0.3.2...HEAD
237
+ [0.3.2]: https://github.com/byteuser1977/ColaMD-themes/compare/v0.3.1...v0.3.2
237
238
  [0.3.1]: https://github.com/byteuser1977/ColaMD-themes/compare/v0.3.0...v0.3.1
238
239
  [0.3.0]: https://github.com/byteuser1977/ColaMD-themes/compare/v0.2.0...v0.3.0
239
240
  [0.2.0]: https://github.com/byteuser1977/ColaMD-themes/compare/v0.1.0...v0.2.0
package/README.md CHANGED
@@ -31,7 +31,7 @@ A theme development & export toolkit for [ColaMD](https://github.com/cola-md/col
31
31
  - **Color System Library** — 15 predefined seed palettes across 5 families (Morandi, Macaron, Nordic, Vintage, Mint)
32
32
  - **Mermaid Presets** — 3 presets (light/dark/elegant) with 20 core variables, auto-selected by luminance and accent warmth
33
33
 
34
- ### Security & Performance (v0.3.1+)
34
+ ### Security & Performance (v0.3.2+)
35
35
 
36
36
  - **SSRF Protection** — URL extractor validates against protocol whitelist and blocks private network access to prevent Server-Side Request Forgery attacks
37
37
  - **Input Validation** — CSS files validated for extension, size limit (1MB max), and content validity to prevent OOM attacks
package/README_CN.md CHANGED
@@ -31,7 +31,7 @@
31
31
  - **色彩系统库** — 5 大色系 15 套预定义种子色板(莫兰迪、马卡龙、北欧、复古、薄荷绿)
32
32
  - **Mermaid 预设** — 3 套预设(light/dark/elegant),20 个核心变量,根据明度和色相自动选择
33
33
 
34
- ### 安全与性能 (v0.3.1+)
34
+ ### 安全与性能 (v0.3.2+)
35
35
 
36
36
  - **SSRF 防护** — URL 提取器通过协议白名单验证并阻止私有网络访问,防止服务器端请求伪造攻击
37
37
  - **输入验证** — CSS 文件经过扩展名、大小限制(最大 1MB)和内容有效性验证,防止 OOM 攻击
package/RELEASENOTE.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Release Notes
2
2
 
3
+ ## Version 0.3.2 (2026-05-29) — Theme Authoring Guide 📝
4
+
5
+ > **AI agent skill enhancement**: Added comprehensive CSS pitfall quick reference for reliable theme generation.
6
+
7
+ ### 📝 AI Agent Skill Update
8
+
9
+ **CSS Pitfall Quick Reference**
10
+ - Added 6-topic theme authoring guide to all AI agent skill definitions:
11
+ 1. **Screen & Print Sync** — every SECTION 5 rule must mirror in SECTION 6 `@media print`
12
+ 2. **Body Text First-Line Indent** — correct selector chain: `body.theme-custom p, body.theme-custom #write > p`
13
+ 3. **Indent Exclusion** — prevent indent pollution in lists, tables, mermaid blocks, blockquotes, and figures
14
+ 4. **List Indentation** — use `margin-left: 2em` instead of `padding-left`; include `#editor .ProseMirror` selectors
15
+ 5. **Mermaid CJK Text Overflow** — ≤ 2 lines per node, `fontSize: 14px`, simplified text
16
+ 6. **Mermaid classDef Inheritance** — must explicitly declare `fill / color / stroke`
17
+ - References `academic-paper.css` and `swiss-design.css` as canonical examples
18
+ - Skill files affected: `.claude/skills/`, `.opencode/skills/`, `.openclaw/skills/`, `.hermes/skills/`, `.trae/rules/`
19
+
20
+ ### 🔧 Changes
21
+
22
+ - Consolidated all unreleased changes from v0.3.1 into this patch release
23
+ - Updated CHANGELOG and version links for the 0.3.2 release
24
+
25
+ ---
26
+
3
27
  ## Version 0.3.1 (2026-06-01) — Security & Stability Patch 🔒
4
28
 
5
29
  > **Important**: This release contains critical security fixes and important stability improvements.