edgemint 0.1.0__tar.gz
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.
- edgemint-0.1.0/.claude/skills/edgemint/SKILL.md +239 -0
- edgemint-0.1.0/.claude/skills/edgemint-packt/SKILL.md +381 -0
- edgemint-0.1.0/.dockerignore +20 -0
- edgemint-0.1.0/.github/workflows/ci.yml +90 -0
- edgemint-0.1.0/.github/workflows/release.yml +139 -0
- edgemint-0.1.0/.gitignore +80 -0
- edgemint-0.1.0/CONTRIBUTING.md +147 -0
- edgemint-0.1.0/Dockerfile +39 -0
- edgemint-0.1.0/LICENSE +102 -0
- edgemint-0.1.0/Makefile +178 -0
- edgemint-0.1.0/PKG-INFO +373 -0
- edgemint-0.1.0/README.md +352 -0
- edgemint-0.1.0/docs/architecture.md +306 -0
- edgemint-0.1.0/docs/cicd-integration.md +289 -0
- edgemint-0.1.0/docs/cli-reference.md +293 -0
- edgemint-0.1.0/docs/index.md +78 -0
- edgemint-0.1.0/docs/packt-author-guide.md +359 -0
- edgemint-0.1.0/docs/quick-start.md +125 -0
- edgemint-0.1.0/docs/release-process.md +225 -0
- edgemint-0.1.0/docs/style-guide.md +241 -0
- edgemint-0.1.0/examples/01-transformer.md +453 -0
- edgemint-0.1.0/examples/README.md +28 -0
- edgemint-0.1.0/examples/packt-book-chapter.md +518 -0
- edgemint-0.1.0/examples/packt-style-author-guide.md +238 -0
- edgemint-0.1.0/examples/packt-style-example-image.png +0 -0
- edgemint-0.1.0/examples/packt-style-example.md +105 -0
- edgemint-0.1.0/examples/packt-style.docx +0 -0
- edgemint-0.1.0/examples/transformer-attention-map.png +0 -0
- edgemint-0.1.0/examples/transformer-layer-stack.png +0 -0
- edgemint-0.1.0/examples/transformer-references.bib +45 -0
- edgemint-0.1.0/examples/transformer-token-geometry.png +0 -0
- edgemint-0.1.0/filters/fix-lists.lua +47 -0
- edgemint-0.1.0/filters/fix-styles.lua +60 -0
- edgemint-0.1.0/pyproject.toml +49 -0
- edgemint-0.1.0/scripts/build_golden_dataset.py +113 -0
- edgemint-0.1.0/scripts/build_packt_author_guide.py +290 -0
- edgemint-0.1.0/scripts/download_golden_fixtures.sh +54 -0
- edgemint-0.1.0/specs/ADR-edgemint.md +1617 -0
- edgemint-0.1.0/specs/docs/claude_code_skill_edgemint.md +411 -0
- edgemint-0.1.0/specs/docs/edgemint_user_guide.md +590 -0
- edgemint-0.1.0/specs/docs/implementation_specification_edgemint_v0_1_0.md +430 -0
- edgemint-0.1.0/src/edgemint/__init__.py +5 -0
- edgemint-0.1.0/src/edgemint/__main__.py +10 -0
- edgemint-0.1.0/src/edgemint/apply.py +1075 -0
- edgemint-0.1.0/src/edgemint/cli.py +195 -0
- edgemint-0.1.0/src/edgemint/diffing.py +65 -0
- edgemint-0.1.0/src/edgemint/errors.py +56 -0
- edgemint-0.1.0/src/edgemint/extract/__init__.py +3 -0
- edgemint-0.1.0/src/edgemint/extract/document.py +833 -0
- edgemint-0.1.0/src/edgemint/extract/resolver.py +70 -0
- edgemint-0.1.0/src/edgemint/extract/security.py +21 -0
- edgemint-0.1.0/src/edgemint/jsonio.py +34 -0
- edgemint-0.1.0/src/edgemint/markdown.py +186 -0
- edgemint-0.1.0/src/edgemint/ooxml.py +28 -0
- edgemint-0.1.0/src/edgemint/pandoc.py +55 -0
- edgemint-0.1.0/src/edgemint/schema/__init__.py +3 -0
- edgemint-0.1.0/src/edgemint/schema/models.py +298 -0
- edgemint-0.1.0/src/edgemint/schema/validators.py +38 -0
- edgemint-0.1.0/tests/conftest.py +42 -0
- edgemint-0.1.0/tests/golden/README.md +16 -0
- edgemint-0.1.0/tests/golden/expected/block_quotes/apply_snapshot.json +59 -0
- edgemint-0.1.0/tests/golden/expected/block_quotes/apply_snapshot_adoc.json +59 -0
- edgemint-0.1.0/tests/golden/expected/block_quotes/content.adoc +21 -0
- edgemint-0.1.0/tests/golden/expected/block_quotes/content.md +19 -0
- edgemint-0.1.0/tests/golden/expected/block_quotes/styles.json +370 -0
- edgemint-0.1.0/tests/golden/expected/block_quotes/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/char_styles/apply_snapshot.json +43 -0
- edgemint-0.1.0/tests/golden/expected/char_styles/apply_snapshot_adoc.json +43 -0
- edgemint-0.1.0/tests/golden/expected/char_styles/content.adoc +7 -0
- edgemint-0.1.0/tests/golden/expected/char_styles/content.md +7 -0
- edgemint-0.1.0/tests/golden/expected/char_styles/styles.json +207 -0
- edgemint-0.1.0/tests/golden/expected/char_styles/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/codeblock/apply_snapshot.json +39 -0
- edgemint-0.1.0/tests/golden/expected/codeblock/apply_snapshot_adoc.json +39 -0
- edgemint-0.1.0/tests/golden/expected/codeblock/content.adoc +9 -0
- edgemint-0.1.0/tests/golden/expected/codeblock/content.md +9 -0
- edgemint-0.1.0/tests/golden/expected/codeblock/styles.json +1140 -0
- edgemint-0.1.0/tests/golden/expected/codeblock/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/having_images/apply_snapshot.json +51 -0
- edgemint-0.1.0/tests/golden/expected/having_images/apply_snapshot_adoc.json +51 -0
- edgemint-0.1.0/tests/golden/expected/having_images/content.adoc +9 -0
- edgemint-0.1.0/tests/golden/expected/having_images/content.md +9 -0
- edgemint-0.1.0/tests/golden/expected/having_images/media/image1.png +0 -0
- edgemint-0.1.0/tests/golden/expected/having_images/media/image2.png +0 -0
- edgemint-0.1.0/tests/golden/expected/having_images/media/image3.png +0 -0
- edgemint-0.1.0/tests/golden/expected/having_images/media/media/image1.png +0 -0
- edgemint-0.1.0/tests/golden/expected/having_images/media/media/image2.png +0 -0
- edgemint-0.1.0/tests/golden/expected/having_images/media/media/image3.png +0 -0
- edgemint-0.1.0/tests/golden/expected/having_images/styles.json +350 -0
- edgemint-0.1.0/tests/golden/expected/having_images/summary.json +9 -0
- edgemint-0.1.0/tests/golden/expected/headers/apply_snapshot.json +79 -0
- edgemint-0.1.0/tests/golden/expected/headers/apply_snapshot_adoc.json +79 -0
- edgemint-0.1.0/tests/golden/expected/headers/content.adoc +25 -0
- edgemint-0.1.0/tests/golden/expected/headers/content.md +25 -0
- edgemint-0.1.0/tests/golden/expected/headers/styles.json +984 -0
- edgemint-0.1.0/tests/golden/expected/headers/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/lists/apply_snapshot.json +75 -0
- edgemint-0.1.0/tests/golden/expected/lists/apply_snapshot_adoc.json +75 -0
- edgemint-0.1.0/tests/golden/expected/lists/content.adoc +38 -0
- edgemint-0.1.0/tests/golden/expected/lists/content.md +45 -0
- edgemint-0.1.0/tests/golden/expected/lists/styles.json +3121 -0
- edgemint-0.1.0/tests/golden/expected/lists/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/notes/apply_snapshot.json +35 -0
- edgemint-0.1.0/tests/golden/expected/notes/apply_snapshot_adoc.json +35 -0
- edgemint-0.1.0/tests/golden/expected/notes/content.adoc +3 -0
- edgemint-0.1.0/tests/golden/expected/notes/content.md +13 -0
- edgemint-0.1.0/tests/golden/expected/notes/styles.json +352 -0
- edgemint-0.1.0/tests/golden/expected/notes/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/tables/apply_snapshot.json +86 -0
- edgemint-0.1.0/tests/golden/expected/tables/apply_snapshot_adoc.json +86 -0
- edgemint-0.1.0/tests/golden/expected/tables/content.adoc +39 -0
- edgemint-0.1.0/tests/golden/expected/tables/content.md +27 -0
- edgemint-0.1.0/tests/golden/expected/tables/styles.json +269 -0
- edgemint-0.1.0/tests/golden/expected/tables/summary.json +4 -0
- edgemint-0.1.0/tests/golden/expected/track_changes_insertion/apply_snapshot.json +31 -0
- edgemint-0.1.0/tests/golden/expected/track_changes_insertion/apply_snapshot_adoc.json +31 -0
- edgemint-0.1.0/tests/golden/expected/track_changes_insertion/content.adoc +1 -0
- edgemint-0.1.0/tests/golden/expected/track_changes_insertion/content.md +1 -0
- edgemint-0.1.0/tests/golden/expected/track_changes_insertion/styles.json +183 -0
- edgemint-0.1.0/tests/golden/expected/track_changes_insertion/summary.json +6 -0
- edgemint-0.1.0/tests/golden/expected/unicode/apply_snapshot.json +31 -0
- edgemint-0.1.0/tests/golden/expected/unicode/apply_snapshot_adoc.json +31 -0
- edgemint-0.1.0/tests/golden/expected/unicode/content.adoc +1 -0
- edgemint-0.1.0/tests/golden/expected/unicode/content.md +1 -0
- edgemint-0.1.0/tests/golden/expected/unicode/styles.json +211 -0
- edgemint-0.1.0/tests/golden/expected/unicode/summary.json +4 -0
- edgemint-0.1.0/tests/test_apply_fallback.py +500 -0
- edgemint-0.1.0/tests/test_apply_more.py +511 -0
- edgemint-0.1.0/tests/test_cli_branches.py +198 -0
- edgemint-0.1.0/tests/test_cli_e2e.py +85 -0
- edgemint-0.1.0/tests/test_cli_misc.py +168 -0
- edgemint-0.1.0/tests/test_diffing.py +32 -0
- edgemint-0.1.0/tests/test_diffing_more.py +34 -0
- edgemint-0.1.0/tests/test_errors_and_io.py +37 -0
- edgemint-0.1.0/tests/test_examples_e2e.py +314 -0
- edgemint-0.1.0/tests/test_extract_helpers.py +342 -0
- edgemint-0.1.0/tests/test_golden_e2e.py +180 -0
- edgemint-0.1.0/tests/test_main_module.py +27 -0
- edgemint-0.1.0/tests/test_markdown.py +25 -0
- edgemint-0.1.0/tests/test_markdown_helpers.py +57 -0
- edgemint-0.1.0/tests/test_pandoc_and_security.py +104 -0
- edgemint-0.1.0/tests/test_pandoc_extra.py +15 -0
- edgemint-0.1.0/tests/test_resolver.py +45 -0
- edgemint-0.1.0/tests/test_resolver_more.py +17 -0
- edgemint-0.1.0/tests/test_validators.py +23 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: edgemint
|
|
3
|
+
description: >
|
|
4
|
+
Generate style-faithful DOCX documents from Markdown using the edgemint CLI.
|
|
5
|
+
Use this skill when the user wants to: create a branded Word document from
|
|
6
|
+
Markdown or AsciiDoc, extract visual styles from a .docx template, regenerate
|
|
7
|
+
a document after editing its content, diff two style sheets, audit a template
|
|
8
|
+
change, or automate a batch document pipeline. Handles all edgemint commands:
|
|
9
|
+
extract-styles, extract, apply-styles, diff, validate, info, schema.
|
|
10
|
+
argument-hint: "[template.docx] [action: extract|apply|diff|batch|inspect]"
|
|
11
|
+
allowed-tools: Bash(edgemint *) Bash(pip install *) Bash(pandoc *) Read Write
|
|
12
|
+
effort: high
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# edgemint — DOCX Style Extraction & Document Generation
|
|
16
|
+
|
|
17
|
+
You are an expert at producing style-faithful Word documents from Markdown
|
|
18
|
+
source using the `edgemint` CLI. You understand DOCX named styles, Pandoc
|
|
19
|
+
Extended Markdown `custom-style` annotations, and the three-file architecture
|
|
20
|
+
(`content.md` + `styles.json` + `media/`).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 0. Prerequisites Check
|
|
25
|
+
|
|
26
|
+
Before any operation, verify edgemint is installed:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
edgemint --version 2>/dev/null || echo "NOT_INSTALLED"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If `NOT_INSTALLED`:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install "edgemint[pandoc]"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Pandoc is required for `extract` and `apply-styles`. Confirm:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pandoc --version 2>/dev/null | head -1 || echo "PANDOC_MISSING"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 1. Core Concept
|
|
47
|
+
|
|
48
|
+
edgemint separates **what a document looks like** from **what it says**:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
template.docx ──extract-styles──► styles.json (visual identity)
|
|
52
|
+
content.md ──apply-styles ──► output.docx (content + identity = output)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`styles.json` is the portable visual identity. Check it into version control.
|
|
56
|
+
`content.md` is plain Pandoc Extended Markdown. Edit it freely.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 2. Workflows
|
|
61
|
+
|
|
62
|
+
### Workflow A — Extract styles from a template
|
|
63
|
+
|
|
64
|
+
When the user has a `.docx` template and wants to understand or capture its styles:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
edgemint extract-styles template.docx -o styles.json --resolved
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then read `styles.json` and summarise:
|
|
71
|
+
- Total style count by type (paragraph / character / table)
|
|
72
|
+
- Key custom styles (non-built-in, branded names)
|
|
73
|
+
- Theme fonts (headings vs. body)
|
|
74
|
+
- Color palette from theme
|
|
75
|
+
|
|
76
|
+
Present a table: `name | type | font | size_pt | color`.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### Workflow B — Generate a styled document
|
|
81
|
+
|
|
82
|
+
When the user wants to produce a branded `.docx` from Markdown content:
|
|
83
|
+
|
|
84
|
+
1. If no `styles.json` exists yet, run Workflow A first.
|
|
85
|
+
2. Read `styles.json` — note every available `name` value precisely.
|
|
86
|
+
3. Write `content.md` using Pandoc Extended Markdown and `custom-style` annotations.
|
|
87
|
+
4. Run `edgemint apply-styles content.md styles.json -o output.docx`.
|
|
88
|
+
5. Confirm the output file exists and report its byte size.
|
|
89
|
+
|
|
90
|
+
**Writing rules for `content.md`:**
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
# Standard Markdown → auto-mapped to DOCX built-in styles
|
|
94
|
+
|
|
95
|
+
# Heading 1 → Heading 1
|
|
96
|
+
## Heading 2 → Heading 2
|
|
97
|
+
|
|
98
|
+
Normal paragraph text → Normal / Body Text
|
|
99
|
+
|
|
100
|
+
**bold** → Strong character style
|
|
101
|
+
*italic* → Emphasis character style
|
|
102
|
+
- Bullet item → List Bullet
|
|
103
|
+
1. Numbered item → List Number
|
|
104
|
+
> Blockquote → Quote
|
|
105
|
+
$E = mc^2$ → OMML equation (Pandoc converts LaTeX)
|
|
106
|
+
 → embedded image with media-dir lookup
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```markdown
|
|
110
|
+
# Named / branded styles → use custom-style annotations
|
|
111
|
+
|
|
112
|
+
::: {custom-style="Heading 1"}
|
|
113
|
+
Chapter Title
|
|
114
|
+
:::
|
|
115
|
+
|
|
116
|
+
::: {custom-style="Body Text"}
|
|
117
|
+
Paragraph content.
|
|
118
|
+
:::
|
|
119
|
+
|
|
120
|
+
The project is [on track]{custom-style="Status Green"}.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Rules:**
|
|
124
|
+
1. **Always use the exact name from `styles.json`** — never guess or invent names.
|
|
125
|
+
2. Prefer standard Markdown over `custom-style` when the auto-mapping is equivalent.
|
|
126
|
+
3. Math: `$...$` inline, `$$...$$` display — Pandoc converts to OMML automatically.
|
|
127
|
+
4. Images: `{width=80%}` — pass `--media` dir to `apply-styles`.
|
|
128
|
+
5. Page breaks: raw OOXML fence:
|
|
129
|
+
````
|
|
130
|
+
```{=openxml}
|
|
131
|
+
<w:p><w:r><w:br w:type="page"/></w:r></w:p>
|
|
132
|
+
```
|
|
133
|
+
````
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Workflow C — Full round-trip extraction
|
|
138
|
+
|
|
139
|
+
When the user wants to decompose an existing `.docx` into editable source:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
edgemint extract document.docx -o project/
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Produces:
|
|
146
|
+
```
|
|
147
|
+
project/
|
|
148
|
+
content.md ← Pandoc Extended Markdown (all content)
|
|
149
|
+
styles.json ← complete visual identity
|
|
150
|
+
media/ ← all embedded images, extracted
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Explain the structure, then tell the user how to re-generate:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
edgemint apply-styles project/content.md project/styles.json \
|
|
157
|
+
-o rebuilt.docx --media project/media
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### Workflow D — Diff / audit styles
|
|
163
|
+
|
|
164
|
+
When the user wants to compare two templates or detect brand changes:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
edgemint extract-styles old-template.docx -o before.json
|
|
168
|
+
edgemint extract-styles new-template.docx -o after.json
|
|
169
|
+
edgemint diff before.json after.json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Present the diff grouped by: **Added**, **Removed**, **Modified** (with exact
|
|
173
|
+
property changes).
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### Workflow E — Batch document generation
|
|
178
|
+
|
|
179
|
+
When the user wants to generate multiple documents from one template:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
edgemint extract-styles template.docx -o styles.json # once
|
|
183
|
+
|
|
184
|
+
for md in docs/*.md; do
|
|
185
|
+
name=$(basename "$md" .md)
|
|
186
|
+
edgemint apply-styles "$md" styles.json -o "output/${name}.docx"
|
|
187
|
+
done
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Write each `.md` file with proper `custom-style` annotations before running the
|
|
191
|
+
loop. Show the user the file count and total output size when done.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### Workflow F — Quick inspection
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
edgemint info document.docx
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Summarise: style count, key custom styles, paragraph vs. character split.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 3. Error Handling
|
|
206
|
+
|
|
207
|
+
| Exit code | Meaning | Action |
|
|
208
|
+
|-----------|---------|--------|
|
|
209
|
+
| 0 | Success | Continue |
|
|
210
|
+
| 1 | Usage error | Show correct usage |
|
|
211
|
+
| 2 | File not found / invalid | Check path, check it's a valid DOCX |
|
|
212
|
+
| 3 | Schema / validation error | Run `edgemint validate styles.json` |
|
|
213
|
+
| 4 | Pandoc error | Run `pandoc --version`; install `edgemint[pandoc]` if missing |
|
|
214
|
+
| 5 | Security error | Warn user — file failed ZIP bomb / path traversal check |
|
|
215
|
+
|
|
216
|
+
Warnings about "style deduplication" and "list style" are normal — edgemint
|
|
217
|
+
auto-fixes both (Pandoc bugs #7280 / #8350). Do not flag them to the user.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 4. Output Confirmation
|
|
222
|
+
|
|
223
|
+
After every `apply-styles` call:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
ls -lh output.docx
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Report: `✓ output.docx (42 KB)` or the equivalent.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 5. Principles
|
|
234
|
+
|
|
235
|
+
- Never modify `styles.json` manually — always re-extract from the source `.docx`.
|
|
236
|
+
- Never invent style names — only use names that appear in `styles.json`.
|
|
237
|
+
- The three-file architecture (`content.md` + `styles.json` + `media/`) maps to
|
|
238
|
+
a natural Git repo layout: content and identity evolve independently.
|
|
239
|
+
- When in doubt, run `edgemint validate styles.json` before generating.
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: edgemint-packt
|
|
3
|
+
description: >
|
|
4
|
+
Write and generate Packt publisher manuscripts as pixel-perfect DOCX using
|
|
5
|
+
edgemint. Use this skill when the user is authoring a Packt book chapter,
|
|
6
|
+
applying Packt house styles, generating or reviewing a Packt-style Word
|
|
7
|
+
document, or converting Markdown to a Packt-compliant manuscript. Knows every
|
|
8
|
+
Packt paragraph style, character style, callout, list level, and code block
|
|
9
|
+
variant. Triggers on: "Packt chapter", "Packt style", "publisher manuscript",
|
|
10
|
+
"Packt template", "write a chapter for Packt", "generate Packt DOCX".
|
|
11
|
+
argument-hint: "[chapter.md | template.docx] [action: write|generate|extract|review]"
|
|
12
|
+
allowed-tools: Bash(edgemint *) Bash(pip install *) Bash(pandoc *) Read Write
|
|
13
|
+
effort: high
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# edgemint — Packt Publisher House Style
|
|
17
|
+
|
|
18
|
+
You are an expert Packt technical author and DOCX production engineer. You
|
|
19
|
+
write chapter Markdown with precise Packt `custom-style` annotations and
|
|
20
|
+
generate pixel-perfect Packt manuscripts using `edgemint`.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 0. Prerequisites
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
edgemint --version 2>/dev/null || pip install "edgemint[pandoc]"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If the user has the Packt Word template (`.docx`), extract the style catalogue:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
edgemint extract-styles packt-template.docx -o packt.json --resolved
|
|
34
|
+
edgemint validate packt.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If no template is available, use the embedded style catalogue in Section 2 of
|
|
38
|
+
this skill — all style names are known and stable across Packt templates.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 1. Packt Authoring Workflow
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
content.md ──► edgemint apply-styles content.md packt.json -o chapter.docx
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The complete authoring loop:
|
|
49
|
+
|
|
50
|
+
1. **Extract** styles from the Packt `.docx` template (once per project).
|
|
51
|
+
2. **Write** chapter Markdown using the style catalogue below.
|
|
52
|
+
3. **Generate** `chapter.docx` with one command.
|
|
53
|
+
4. **Review** only the Word output — never edit the `.docx` directly.
|
|
54
|
+
5. **Iterate** in `content.md` until the chapter is approved.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 2. Complete Packt Style Catalogue
|
|
59
|
+
|
|
60
|
+
These are the canonical Packt named styles. Use **exact** names.
|
|
61
|
+
|
|
62
|
+
### Chapter openers
|
|
63
|
+
|
|
64
|
+
```markdown
|
|
65
|
+
::: {custom-style="HS - ChapterNumber"}
|
|
66
|
+
Chapter 3
|
|
67
|
+
:::
|
|
68
|
+
|
|
69
|
+
::: {custom-style="HS - ChapterTitle"}
|
|
70
|
+
Understanding Transformer Architectures
|
|
71
|
+
:::
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| Style | Purpose |
|
|
75
|
+
|-------|--------|
|
|
76
|
+
| `HS - ChapterNumber` | "Chapter N" label at chapter top |
|
|
77
|
+
| `HS - ChapterTitle` | Chapter title text |
|
|
78
|
+
| `HS - Heading 1` | Major section header |
|
|
79
|
+
| `HS - Heading 2` | Sub-section header |
|
|
80
|
+
| `HS - Heading 3` | Sub-sub-section header |
|
|
81
|
+
| `HS - Heading 4` | Lowest heading level |
|
|
82
|
+
|
|
83
|
+
### Body text
|
|
84
|
+
|
|
85
|
+
| Style | Purpose |
|
|
86
|
+
|-------|--------|
|
|
87
|
+
| `P0 - Paragraph` | Primary Packt body paragraph (use after callouts and headings) |
|
|
88
|
+
| `P0 - ParagraphCenter` | Centred paragraph (epigraphs, visual breaks) |
|
|
89
|
+
| `P1 - Paragraph` | Secondary body paragraph (lighter typographic weight) |
|
|
90
|
+
|
|
91
|
+
### Callout boxes
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
::: {custom-style="I - InfoBox"}
|
|
95
|
+
**Tip header.** Body of the callout. Keep it to three sentences or fewer.
|
|
96
|
+
:::
|
|
97
|
+
|
|
98
|
+
::: {custom-style="T - TipBox"}
|
|
99
|
+
**Tip.** This tip should change one concrete decision. If it doesn't, cut it.
|
|
100
|
+
:::
|
|
101
|
+
|
|
102
|
+
::: {custom-style="C - Citation"}
|
|
103
|
+
"A production ML pipeline fails first at the seam between intention and
|
|
104
|
+
repeatability."
|
|
105
|
+
:::
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| Style | Purpose |
|
|
109
|
+
|-------|--------|
|
|
110
|
+
| `I - InfoBox` | Background information callout |
|
|
111
|
+
| `T - TipBox` | Actionable tip (must suggest a concrete action) |
|
|
112
|
+
| `C - Citation` | Block quotation |
|
|
113
|
+
| `QS - Quote` | Standalone pull-quote |
|
|
114
|
+
|
|
115
|
+
### Code listings
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
::: {custom-style="C0 - CodeBlock"}
|
|
119
|
+
def train_step(model, batch):
|
|
120
|
+
logits = model(batch["input_ids"])
|
|
121
|
+
return loss_fn(logits, batch["labels"])
|
|
122
|
+
:::
|
|
123
|
+
|
|
124
|
+
::: {custom-style="C0 - ConsoleBlock"}
|
|
125
|
+
$ python train.py --epochs 10 --lr 1e-4
|
|
126
|
+
Epoch 1/10: loss=2.34
|
|
127
|
+
:::
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
| Style | Purpose |
|
|
131
|
+
|-------|--------|
|
|
132
|
+
| `C0 - CodeBlock` | Primary code listing (Python, YAML, JSON, etc.) |
|
|
133
|
+
| `C0 - ConsoleBlock` | Terminal / shell session output |
|
|
134
|
+
| `C1 - CodeBlock` | Secondary code listing (alternative for contrast) |
|
|
135
|
+
| `C1 - ConsoleBlock` | Secondary console output |
|
|
136
|
+
|
|
137
|
+
> **Rule:** never use fenced code blocks (` ``` `) in Packt manuscripts. Always
|
|
138
|
+
> use the `custom-style` div form above so the correct Packt monospace font applies.
|
|
139
|
+
|
|
140
|
+
### Lists
|
|
141
|
+
|
|
142
|
+
Use native Markdown lists whenever the auto-mapping is sufficient. For
|
|
143
|
+
explicit Packt list styles:
|
|
144
|
+
|
|
145
|
+
```markdown
|
|
146
|
+
::: {custom-style="L1 - Bullet"}
|
|
147
|
+
Level 1 bullet item.
|
|
148
|
+
:::
|
|
149
|
+
|
|
150
|
+
::: {custom-style="L2 - Bullet"}
|
|
151
|
+
Nested level 2 bullet.
|
|
152
|
+
:::
|
|
153
|
+
|
|
154
|
+
::: {custom-style="L1 - Numbered"}
|
|
155
|
+
First numbered step.
|
|
156
|
+
:::
|
|
157
|
+
|
|
158
|
+
::: {custom-style="L2 - Numbered"}
|
|
159
|
+
Nested numbered sub-step.
|
|
160
|
+
:::
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Full list style catalogue:
|
|
164
|
+
|
|
165
|
+
| Style | Purpose |
|
|
166
|
+
|-------|--------|
|
|
167
|
+
| `L1 - Bullet` / `L2 - Bullet` / `L3 - Bullet` | Bullet list levels 1–3 |
|
|
168
|
+
| `L1 - Numbered` / `L2 - Numbered` / `L3 - Numbered` | Numbered list levels 1–3 |
|
|
169
|
+
| `L1 - Alphabet` / `L2 - Alphabet` / `L3 - Alphabet` | Alphabetic list levels 1–3 |
|
|
170
|
+
|
|
171
|
+
### Figures and captions
|
|
172
|
+
|
|
173
|
+
```markdown
|
|
174
|
+
{ width=80% }
|
|
175
|
+
|
|
176
|
+
::: {custom-style="F0 - FigureCaption"}
|
|
177
|
+
Figure 3.1 — Self-attention scores for a single head across 512 token
|
|
178
|
+
positions. The diagonal shows each token attending primarily to itself during
|
|
179
|
+
early training.
|
|
180
|
+
:::
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
| Style | Purpose |
|
|
184
|
+
|-------|--------|
|
|
185
|
+
| `F0 - Figure` | Figure container paragraph |
|
|
186
|
+
| `F0 - FigureCaption` | Caption immediately below figure |
|
|
187
|
+
|
|
188
|
+
Always store images in `media/` and pass `--media media` when generating:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
edgemint apply-styles chapter.md packt.json -o chapter.docx --media media
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Tables
|
|
195
|
+
|
|
196
|
+
Wrap tables in the `TS - Table` style:
|
|
197
|
+
|
|
198
|
+
```markdown
|
|
199
|
+
::: {custom-style="TS - Table"}
|
|
200
|
+
| Header A | Header B | Header C |
|
|
201
|
+
|:-----------------|:----------------------|:------------------|
|
|
202
|
+
| Row 1 cell | Row 1 cell | Row 1 cell |
|
|
203
|
+
| Row 2 cell | Row 2 cell | Row 2 cell |
|
|
204
|
+
:::
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
| Style | Purpose |
|
|
208
|
+
|-------|--------|
|
|
209
|
+
| `TS - Table` | Outer table wrapper |
|
|
210
|
+
| `TS - TableBullet` | Bullet item inside a table cell |
|
|
211
|
+
| `TS - TableCenter` | Centred text in a table cell |
|
|
212
|
+
| `TS - TableNumberedList` | Numbered item inside a table cell |
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 3. Inline Character Styles
|
|
217
|
+
|
|
218
|
+
Apply within paragraph text using the bracketed span syntax:
|
|
219
|
+
|
|
220
|
+
```markdown
|
|
221
|
+
The [transformer]{custom-style="CS - Keyword"} model calls
|
|
222
|
+
[self_attention()]{custom-style="CS - InlineCode"} to compute scores.
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
| Style | Use for |
|
|
226
|
+
|-------|--------|
|
|
227
|
+
| `CS - Keyword` | Technical terms, model names, product names |
|
|
228
|
+
| `CS - InlineCode` | Code identifiers, function names, CLI flags |
|
|
229
|
+
| `CS - BoldItalic` | Strong combined emphasis (use sparingly) |
|
|
230
|
+
| `CS - Italic` | Editorial asides, first-use definitions |
|
|
231
|
+
| `CS - URL` | Hyperlinks (alternative to standard Markdown link syntax) |
|
|
232
|
+
| `CS - Screentext` | UI labels, menu items, button names |
|
|
233
|
+
| `CS - Subscript` | Chemical formulae, math subscripts |
|
|
234
|
+
| `CS - Superscript` | Footnote anchors, math superscripts |
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 4. Complete Chapter Template
|
|
239
|
+
|
|
240
|
+
Use this as the starting structure for every new Packt chapter:
|
|
241
|
+
|
|
242
|
+
```markdown
|
|
243
|
+
---
|
|
244
|
+
title: "Chapter N: Chapter Title"
|
|
245
|
+
author: "Author Name"
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
::: {custom-style="HS - ChapterNumber"}
|
|
249
|
+
Chapter N
|
|
250
|
+
:::
|
|
251
|
+
|
|
252
|
+
::: {custom-style="HS - ChapterTitle"}
|
|
253
|
+
Chapter Title
|
|
254
|
+
:::
|
|
255
|
+
|
|
256
|
+
::: {custom-style="P0 - Paragraph"}
|
|
257
|
+
Opening paragraph of the chapter — sets the scene and provides a concrete
|
|
258
|
+
problem statement. Keep to 3–5 sentences.
|
|
259
|
+
:::
|
|
260
|
+
|
|
261
|
+
# Section Heading
|
|
262
|
+
|
|
263
|
+
::: {custom-style="P0 - Paragraph"}
|
|
264
|
+
First paragraph of a new section. Use P0 after headings.
|
|
265
|
+
:::
|
|
266
|
+
|
|
267
|
+
Body text that continues directly uses standard Markdown paragraphs, which
|
|
268
|
+
map to the Normal style automatically.
|
|
269
|
+
|
|
270
|
+
## Sub-section Heading
|
|
271
|
+
|
|
272
|
+
::: {custom-style="I - InfoBox"}
|
|
273
|
+
**Important.** Add critical context here that a reader must have before
|
|
274
|
+
proceeding. One or two sentences.
|
|
275
|
+
:::
|
|
276
|
+
|
|
277
|
+
### Code Example
|
|
278
|
+
|
|
279
|
+
::: {custom-style="C0 - ConsoleBlock"}
|
|
280
|
+
$ python --version
|
|
281
|
+
Python 3.12.0
|
|
282
|
+
:::
|
|
283
|
+
|
|
284
|
+
::: {custom-style="C0 - CodeBlock"}
|
|
285
|
+
import torch
|
|
286
|
+
|
|
287
|
+
model = TransformerModel(vocab_size=50257, d_model=768)
|
|
288
|
+
output = model(input_ids)
|
|
289
|
+
:::
|
|
290
|
+
|
|
291
|
+
::: {custom-style="P0 - Paragraph"}
|
|
292
|
+
The paragraph immediately following a code listing explains what the code does.
|
|
293
|
+
Never leave code blocks without explanatory text.
|
|
294
|
+
:::
|
|
295
|
+
|
|
296
|
+
# Summary
|
|
297
|
+
|
|
298
|
+
::: {custom-style="P0 - Paragraph"}
|
|
299
|
+
Summary paragraph. Bullet the three key takeaways of the chapter below.
|
|
300
|
+
:::
|
|
301
|
+
|
|
302
|
+
- First key takeaway.
|
|
303
|
+
- Second key takeaway.
|
|
304
|
+
- Third key takeaway.
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## 5. Packt House Rules
|
|
310
|
+
|
|
311
|
+
Follow these rules when writing content:
|
|
312
|
+
|
|
313
|
+
1. **No orphan code blocks** — every code listing must be preceded and followed by explanatory prose.
|
|
314
|
+
2. **InfoBox / TipBox sparingly** — maximum one callout per sub-section.
|
|
315
|
+
3. **Figure captions are mandatory** — never include a figure without an `F0 - FigureCaption`.
|
|
316
|
+
4. **Chapter number in `HS - ChapterNumber`** — this is separate from the title.
|
|
317
|
+
5. **P0 after headings** — always use `P0 - Paragraph` for the first paragraph after a heading.
|
|
318
|
+
6. **Avoid passive voice** in code comments and captions.
|
|
319
|
+
7. **Code in console blocks uses `$` prompt** — never use `>>>` for shell commands.
|
|
320
|
+
8. **All URLs are hyperlinks** — use `[text](url)` or `{custom-style="CS - URL"}`.
|
|
321
|
+
9. **Figure numbering** — `Figure N.M — Description.` (chapter number dot figure number, em dash).
|
|
322
|
+
10. **Table caption** — place above the table using a plain paragraph: `*Table N.M — Description.*`
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## 6. Generating the Manuscript
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Single chapter
|
|
330
|
+
edgemint apply-styles chapter-03.md packt.json -o chapter-03.docx --media media
|
|
331
|
+
|
|
332
|
+
# All chapters in a book
|
|
333
|
+
for md in chapters/chapter-*.md; do
|
|
334
|
+
base=$(basename "$md" .md)
|
|
335
|
+
edgemint apply-styles "$md" packt.json -o "output/${base}.docx" --media media
|
|
336
|
+
done
|
|
337
|
+
ls -lh output/
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
After generation, confirm:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
edgemint info output/chapter-03.docx
|
|
344
|
+
# Shows style count — verify it matches your template
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 7. Validating the Style Sheet
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
edgemint validate packt.json # → Valid (exit 0)
|
|
353
|
+
|
|
354
|
+
# List all available Packt style names
|
|
355
|
+
python3 -c "
|
|
356
|
+
import json
|
|
357
|
+
for s in json.load(open('packt.json'))['styles']:
|
|
358
|
+
print(f\"{s['type']:15} {s['name']}\")
|
|
359
|
+
" | sort
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## 8. Error Handling
|
|
365
|
+
|
|
366
|
+
| Symptom | Cause | Fix |
|
|
367
|
+
|---------|-------|-----|
|
|
368
|
+
| Style not applying | Wrong style name (typo or case) | Check exact name in`packt.json` |
|
|
369
|
+
| Images missing | `--media` not passed | Add `--media media` to the command |
|
|
370
|
+
| Font looks wrong | Font not embedded in template | Re-extract from the original `.docx` |
|
|
371
|
+
| `exit 4` | Pandoc missing | `pip install "edgemint[pandoc]"` |
|
|
372
|
+
| `exit 5` | Security error | File failed ZIP inspection — use a clean template |
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## 9. Further Reading
|
|
377
|
+
|
|
378
|
+
- [Packt Author Guide](docs/packt-author-guide.md) — complete human-readable authoring guide
|
|
379
|
+
- [edgemint Skill](.claude/skills/edgemint/SKILL.md) — general (non-Packt) document generation
|
|
380
|
+
- [Style Guide](docs/style-guide.md) — `custom-style` annotation reference
|
|
381
|
+
- [CLI Reference](docs/cli-reference.md) — all commands and flags
|