docrev 0.9.11 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +9 -9
- package/.gitattributes +1 -1
- package/CHANGELOG.md +149 -149
- package/PLAN-tables-and-postprocess.md +850 -850
- package/README.md +391 -391
- package/bin/rev.js +11 -11
- package/bin/rev.ts +145 -145
- package/completions/rev.bash +127 -127
- package/completions/rev.ps1 +210 -210
- package/completions/rev.zsh +207 -207
- package/dev_notes/stress2/build_adversarial.ts +186 -186
- package/dev_notes/stress2/drift_matcher.ts +62 -62
- package/dev_notes/stress2/probe_anchors.ts +35 -35
- package/dev_notes/stress2/project/discussion.before.md +3 -3
- package/dev_notes/stress2/project/discussion.md +3 -3
- package/dev_notes/stress2/project/methods.before.md +20 -20
- package/dev_notes/stress2/project/methods.md +20 -20
- package/dev_notes/stress2/project/rev.yaml +5 -5
- package/dev_notes/stress2/project/sections.yaml +4 -4
- package/dev_notes/stress2/sections.yaml +5 -5
- package/dev_notes/stress2/trace_placement.ts +50 -50
- package/dev_notes/stresstest_boundaries.ts +27 -27
- package/dev_notes/stresstest_drift_apply.ts +43 -43
- package/dev_notes/stresstest_drift_compare.ts +43 -43
- package/dev_notes/stresstest_drift_v2.ts +54 -54
- package/dev_notes/stresstest_inspect.ts +54 -54
- package/dev_notes/stresstest_pstyle.ts +55 -55
- package/dev_notes/stresstest_section_debug.ts +23 -23
- package/dev_notes/stresstest_split.ts +70 -70
- package/dev_notes/stresstest_trace.ts +19 -19
- package/dev_notes/stresstest_verify_no_overwrite.ts +40 -40
- package/dist/lib/build.d.ts +50 -1
- package/dist/lib/build.d.ts.map +1 -1
- package/dist/lib/build.js +80 -30
- package/dist/lib/build.js.map +1 -1
- package/dist/lib/commands/build.d.ts.map +1 -1
- package/dist/lib/commands/build.js +38 -5
- package/dist/lib/commands/build.js.map +1 -1
- package/dist/lib/commands/utilities.js +164 -164
- package/dist/lib/commands/word-tools.js +8 -8
- package/dist/lib/grammar.js +3 -3
- package/dist/lib/import.d.ts.map +1 -1
- package/dist/lib/import.js +146 -24
- package/dist/lib/import.js.map +1 -1
- package/dist/lib/pdf-comments.js +44 -44
- package/dist/lib/plugins.js +57 -57
- package/dist/lib/pptx-themes.js +115 -115
- package/dist/lib/spelling.js +2 -2
- package/dist/lib/templates.js +387 -387
- package/dist/lib/themes.js +51 -51
- package/dist/lib/types.d.ts +20 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/word-extraction.d.ts +6 -0
- package/dist/lib/word-extraction.d.ts.map +1 -1
- package/dist/lib/word-extraction.js +46 -3
- package/dist/lib/word-extraction.js.map +1 -1
- package/dist/lib/wordcomments.d.ts.map +1 -1
- package/dist/lib/wordcomments.js +23 -5
- package/dist/lib/wordcomments.js.map +1 -1
- package/eslint.config.js +27 -27
- package/lib/anchor-match.ts +276 -276
- package/lib/annotations.ts +644 -644
- package/lib/build.ts +1300 -1227
- package/lib/citations.ts +160 -160
- package/lib/commands/build.ts +833 -801
- package/lib/commands/citations.ts +515 -515
- package/lib/commands/comments.ts +1050 -1050
- package/lib/commands/context.ts +174 -174
- package/lib/commands/core.ts +309 -309
- package/lib/commands/doi.ts +435 -435
- package/lib/commands/file-ops.ts +372 -372
- package/lib/commands/history.ts +320 -320
- package/lib/commands/index.ts +87 -87
- package/lib/commands/init.ts +259 -259
- package/lib/commands/merge-resolve.ts +378 -378
- package/lib/commands/preview.ts +178 -178
- package/lib/commands/project-info.ts +244 -244
- package/lib/commands/quality.ts +517 -517
- package/lib/commands/response.ts +454 -454
- package/lib/commands/section-boundaries.ts +82 -82
- package/lib/commands/sections.ts +451 -451
- package/lib/commands/sync.ts +706 -706
- package/lib/commands/text-ops.ts +449 -449
- package/lib/commands/utilities.ts +448 -448
- package/lib/commands/verify-anchors.ts +272 -272
- package/lib/commands/word-tools.ts +340 -340
- package/lib/comment-realign.ts +517 -517
- package/lib/config.ts +84 -84
- package/lib/crossref.ts +781 -781
- package/lib/csl.ts +191 -191
- package/lib/dependencies.ts +98 -98
- package/lib/diff-engine.ts +465 -465
- package/lib/doi-cache.ts +115 -115
- package/lib/doi.ts +897 -897
- package/lib/equations.ts +506 -506
- package/lib/errors.ts +346 -346
- package/lib/format.ts +541 -541
- package/lib/git.ts +326 -326
- package/lib/grammar.ts +303 -303
- package/lib/image-registry.ts +180 -180
- package/lib/import.ts +911 -792
- package/lib/journals.ts +543 -543
- package/lib/merge.ts +633 -633
- package/lib/orcid.ts +144 -144
- package/lib/pdf-comments.ts +263 -263
- package/lib/pdf-import.ts +524 -524
- package/lib/plugins.ts +362 -362
- package/lib/postprocess.ts +188 -188
- package/lib/pptx-color-filter.lua +37 -37
- package/lib/pptx-template.ts +469 -469
- package/lib/pptx-themes.ts +483 -483
- package/lib/protect-restore.ts +520 -520
- package/lib/rate-limiter.ts +94 -94
- package/lib/response.ts +197 -197
- package/lib/restore-references.ts +240 -240
- package/lib/review.ts +327 -327
- package/lib/schema.ts +417 -417
- package/lib/scientific-words.ts +73 -73
- package/lib/sections.ts +335 -335
- package/lib/slides.ts +756 -756
- package/lib/spelling.ts +334 -334
- package/lib/templates.ts +526 -526
- package/lib/themes.ts +742 -742
- package/lib/trackchanges.ts +247 -247
- package/lib/tui.ts +450 -450
- package/lib/types.ts +550 -530
- package/lib/undo.ts +250 -250
- package/lib/utils.ts +69 -69
- package/lib/variables.ts +179 -179
- package/lib/word-extraction.ts +806 -759
- package/lib/word.ts +643 -643
- package/lib/wordcomments.ts +817 -798
- package/package.json +137 -137
- package/scripts/postbuild.js +28 -28
- package/skill/REFERENCE.md +431 -431
- package/skill/SKILL.md +258 -258
- package/tsconfig.json +26 -26
- package/types/index.d.ts +525 -525
package/lib/pptx-themes.ts
CHANGED
|
@@ -1,483 +1,483 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PPTX Theme System
|
|
3
|
-
*
|
|
4
|
-
* Provides 6 built-in themes for PPTX output, independent of Beamer themes.
|
|
5
|
-
* Each theme is a reference PPTX file that defines colors, fonts, and slide layouts.
|
|
6
|
-
*
|
|
7
|
-
* Uses pandoc's default reference.pptx as the base template and modifies the theme.xml
|
|
8
|
-
* to apply custom colors and fonts. This ensures all 11 required slide layouts are present.
|
|
9
|
-
*
|
|
10
|
-
* Themes:
|
|
11
|
-
* - default: Clean white with blue accents (professional)
|
|
12
|
-
* - dark: Dark background with light text (modern)
|
|
13
|
-
* - academic: Classic serif fonts, muted colors (scholarly)
|
|
14
|
-
* - minimal: High contrast black/white (clean)
|
|
15
|
-
* - corporate: Navy/gold color scheme (business)
|
|
16
|
-
* - plant: Nature-inspired green theme (ecology/biology)
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
20
|
-
import { join, dirname } from 'node:path';
|
|
21
|
-
import { fileURLToPath } from 'node:url';
|
|
22
|
-
import { execSync } from 'node:child_process';
|
|
23
|
-
import AdmZip from 'adm-zip';
|
|
24
|
-
|
|
25
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Color scheme for a theme
|
|
29
|
-
*/
|
|
30
|
-
interface ThemeColors {
|
|
31
|
-
dk1: string;
|
|
32
|
-
lt1: string;
|
|
33
|
-
dk2: string;
|
|
34
|
-
lt2: string;
|
|
35
|
-
accent1: string;
|
|
36
|
-
accent2: string;
|
|
37
|
-
accent3: string;
|
|
38
|
-
accent4: string;
|
|
39
|
-
accent5: string;
|
|
40
|
-
accent6: string;
|
|
41
|
-
hlink: string;
|
|
42
|
-
folHlink: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Font scheme for a theme
|
|
47
|
-
*/
|
|
48
|
-
interface ThemeFonts {
|
|
49
|
-
major: string;
|
|
50
|
-
minor: string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* PPTX theme definition
|
|
55
|
-
*/
|
|
56
|
-
interface PptxTheme {
|
|
57
|
-
name: string;
|
|
58
|
-
description: string;
|
|
59
|
-
colors: ThemeColors;
|
|
60
|
-
fonts: ThemeFonts;
|
|
61
|
-
background?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Theme definitions with colors and fonts
|
|
66
|
-
*/
|
|
67
|
-
export const PPTX_THEMES: Record<string, PptxTheme> = {
|
|
68
|
-
default: {
|
|
69
|
-
name: 'Default',
|
|
70
|
-
description: 'Clean white with blue accents',
|
|
71
|
-
colors: {
|
|
72
|
-
dk1: '000000', // Dark text
|
|
73
|
-
lt1: 'FFFFFF', // Light background
|
|
74
|
-
dk2: '1F497D', // Dark accent (navy)
|
|
75
|
-
lt2: 'EEECE1', // Light accent (cream)
|
|
76
|
-
accent1: '4472C4', // Blue
|
|
77
|
-
accent2: 'ED7D31', // Orange
|
|
78
|
-
accent3: 'A5A5A5', // Gray
|
|
79
|
-
accent4: 'FFC000', // Yellow
|
|
80
|
-
accent5: '5B9BD5', // Light blue
|
|
81
|
-
accent6: '70AD47', // Green
|
|
82
|
-
hlink: '0563C1', // Hyperlink blue
|
|
83
|
-
folHlink: '954F72', // Followed hyperlink
|
|
84
|
-
},
|
|
85
|
-
fonts: {
|
|
86
|
-
major: 'Calibri Light',
|
|
87
|
-
minor: 'Calibri',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
dark: {
|
|
91
|
-
name: 'Dark',
|
|
92
|
-
description: 'Dark background with light text',
|
|
93
|
-
colors: {
|
|
94
|
-
dk1: 'FFFFFF', // Light text (inverted)
|
|
95
|
-
lt1: '1E1E1E', // Dark background
|
|
96
|
-
dk2: 'E0E0E0', // Light gray
|
|
97
|
-
lt2: '2D2D2D', // Darker gray
|
|
98
|
-
accent1: '00B4D8', // Cyan
|
|
99
|
-
accent2: 'FF6B6B', // Coral
|
|
100
|
-
accent3: '95E1D3', // Mint
|
|
101
|
-
accent4: 'F38181', // Pink
|
|
102
|
-
accent5: 'AA96DA', // Lavender
|
|
103
|
-
accent6: 'FCBAD3', // Light pink
|
|
104
|
-
hlink: '00B4D8',
|
|
105
|
-
folHlink: 'AA96DA',
|
|
106
|
-
},
|
|
107
|
-
fonts: {
|
|
108
|
-
major: 'Inter',
|
|
109
|
-
minor: 'Inter',
|
|
110
|
-
},
|
|
111
|
-
background: '1E1E1E',
|
|
112
|
-
},
|
|
113
|
-
academic: {
|
|
114
|
-
name: 'Academic',
|
|
115
|
-
description: 'Classic serif fonts, muted colors',
|
|
116
|
-
colors: {
|
|
117
|
-
dk1: '2C3E50', // Dark blue-gray
|
|
118
|
-
lt1: 'FFFEF9', // Warm white
|
|
119
|
-
dk2: '34495E', // Slate
|
|
120
|
-
lt2: 'F5F5DC', // Beige
|
|
121
|
-
accent1: '8B4513', // Saddle brown
|
|
122
|
-
accent2: '2E8B57', // Sea green
|
|
123
|
-
accent3: '708090', // Slate gray
|
|
124
|
-
accent4: 'B8860B', // Dark goldenrod
|
|
125
|
-
accent5: '4682B4', // Steel blue
|
|
126
|
-
accent6: '6B8E23', // Olive drab
|
|
127
|
-
hlink: '8B4513',
|
|
128
|
-
folHlink: '708090',
|
|
129
|
-
},
|
|
130
|
-
fonts: {
|
|
131
|
-
major: 'Georgia',
|
|
132
|
-
minor: 'Palatino Linotype',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
minimal: {
|
|
136
|
-
name: 'Minimal',
|
|
137
|
-
description: 'High contrast black and white',
|
|
138
|
-
colors: {
|
|
139
|
-
dk1: '000000', // Pure black
|
|
140
|
-
lt1: 'FFFFFF', // Pure white
|
|
141
|
-
dk2: '333333', // Dark gray
|
|
142
|
-
lt2: 'F0F0F0', // Light gray
|
|
143
|
-
accent1: '000000', // Black accent
|
|
144
|
-
accent2: '666666', // Medium gray
|
|
145
|
-
accent3: '999999', // Light gray
|
|
146
|
-
accent4: 'CCCCCC', // Lighter gray
|
|
147
|
-
accent5: '333333', // Dark gray
|
|
148
|
-
accent6: '4D4D4D', // Charcoal
|
|
149
|
-
hlink: '000000',
|
|
150
|
-
folHlink: '666666',
|
|
151
|
-
},
|
|
152
|
-
fonts: {
|
|
153
|
-
major: 'Roboto Light',
|
|
154
|
-
minor: 'Roboto',
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
corporate: {
|
|
158
|
-
name: 'Corporate',
|
|
159
|
-
description: 'Navy and gold professional theme',
|
|
160
|
-
colors: {
|
|
161
|
-
dk1: '0D1B2A', // Very dark navy
|
|
162
|
-
lt1: 'FFFFFF', // White
|
|
163
|
-
dk2: '1B263B', // Dark navy
|
|
164
|
-
lt2: 'E0E1DD', // Light gray
|
|
165
|
-
accent1: 'D4AF37', // Gold
|
|
166
|
-
accent2: '415A77', // Steel blue
|
|
167
|
-
accent3: '778DA9', // Light steel
|
|
168
|
-
accent4: 'C5A900', // Darker gold
|
|
169
|
-
accent5: '1B4965', // Deep blue
|
|
170
|
-
accent6: '5FA8D3', // Sky blue
|
|
171
|
-
hlink: 'D4AF37',
|
|
172
|
-
folHlink: '778DA9',
|
|
173
|
-
},
|
|
174
|
-
fonts: {
|
|
175
|
-
major: 'Garamond',
|
|
176
|
-
minor: 'Garamond',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
plant: {
|
|
180
|
-
name: 'Plant',
|
|
181
|
-
description: 'Nature-inspired green theme for ecology/biology',
|
|
182
|
-
colors: {
|
|
183
|
-
dk1: '2D4A22', // Dark forest green
|
|
184
|
-
lt1: 'FFFFFF', // White
|
|
185
|
-
dk2: '3D5A2E', // Medium forest
|
|
186
|
-
lt2: 'F5F7F2', // Light sage
|
|
187
|
-
accent1: '608C32', // Primary green (theme accent)
|
|
188
|
-
accent2: '8B4513', // Earth brown
|
|
189
|
-
accent3: '888888', // Gray (for buildup)
|
|
190
|
-
accent4: '7CB342', // Light green
|
|
191
|
-
accent5: '4A6B3A', // Olive green
|
|
192
|
-
accent6: 'A5D6A7', // Pale green
|
|
193
|
-
hlink: '608C32',
|
|
194
|
-
folHlink: '4A6B3A',
|
|
195
|
-
},
|
|
196
|
-
fonts: {
|
|
197
|
-
major: 'Aptos Display',
|
|
198
|
-
minor: 'Aptos',
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Get list of available theme names
|
|
205
|
-
*/
|
|
206
|
-
export function getThemeNames(): string[] {
|
|
207
|
-
return Object.keys(PPTX_THEMES);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Get theme definition by name
|
|
212
|
-
*/
|
|
213
|
-
export function getTheme(name: string): PptxTheme | null {
|
|
214
|
-
return PPTX_THEMES[name] || null;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Generate [Content_Types].xml
|
|
219
|
-
*/
|
|
220
|
-
function generateContentTypes(): string {
|
|
221
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
222
|
-
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
223
|
-
<Default Extension="jpeg" ContentType="image/jpeg"/>
|
|
224
|
-
<Default Extension="png" ContentType="image/png"/>
|
|
225
|
-
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
226
|
-
<Default Extension="xml" ContentType="application/xml"/>
|
|
227
|
-
<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>
|
|
228
|
-
<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>
|
|
229
|
-
<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
|
|
230
|
-
<Override PartName="/ppt/slideLayouts/slideLayout2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
|
|
231
|
-
<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
|
|
232
|
-
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
|
|
233
|
-
<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
|
|
234
|
-
</Types>`;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Generate _rels/.rels
|
|
239
|
-
*/
|
|
240
|
-
function generateRels(): string {
|
|
241
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
242
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
243
|
-
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
|
244
|
-
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
|
|
245
|
-
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
|
|
246
|
-
</Relationships>`;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Generate ppt/_rels/presentation.xml.rels
|
|
251
|
-
*/
|
|
252
|
-
function generatePresentationRels(): string {
|
|
253
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
254
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
255
|
-
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>
|
|
256
|
-
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
|
|
257
|
-
</Relationships>`;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Generate ppt/presentation.xml
|
|
262
|
-
*/
|
|
263
|
-
function generatePresentation(): string {
|
|
264
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
265
|
-
<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" saveSubsetFonts="1">
|
|
266
|
-
<p:sldMasterIdLst>
|
|
267
|
-
<p:sldMasterId id="2147483648" r:id="rId1"/>
|
|
268
|
-
</p:sldMasterIdLst>
|
|
269
|
-
<p:sldSz cx="12192000" cy="6858000"/>
|
|
270
|
-
<p:notesSz cx="6858000" cy="9144000"/>
|
|
271
|
-
<p:defaultTextStyle>
|
|
272
|
-
<a:defPPr>
|
|
273
|
-
<a:defRPr lang="en-US"/>
|
|
274
|
-
</a:defPPr>
|
|
275
|
-
</p:defaultTextStyle>
|
|
276
|
-
</p:presentation>`;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Generate ppt/theme/theme1.xml with theme colors and fonts
|
|
281
|
-
*/
|
|
282
|
-
function generateTheme(theme: PptxTheme): string {
|
|
283
|
-
const c = theme.colors;
|
|
284
|
-
const f = theme.fonts;
|
|
285
|
-
|
|
286
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
287
|
-
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${theme.name}">
|
|
288
|
-
<a:themeElements>
|
|
289
|
-
<a:clrScheme name="${theme.name}">
|
|
290
|
-
<a:dk1><a:srgbClr val="${c.dk1}"/></a:dk1>
|
|
291
|
-
<a:lt1><a:srgbClr val="${c.lt1}"/></a:lt1>
|
|
292
|
-
<a:dk2><a:srgbClr val="${c.dk2}"/></a:dk2>
|
|
293
|
-
<a:lt2><a:srgbClr val="${c.lt2}"/></a:lt2>
|
|
294
|
-
<a:accent1><a:srgbClr val="${c.accent1}"/></a:accent1>
|
|
295
|
-
<a:accent2><a:srgbClr val="${c.accent2}"/></a:accent2>
|
|
296
|
-
<a:accent3><a:srgbClr val="${c.accent3}"/></a:accent3>
|
|
297
|
-
<a:accent4><a:srgbClr val="${c.accent4}"/></a:accent4>
|
|
298
|
-
<a:accent5><a:srgbClr val="${c.accent5}"/></a:accent5>
|
|
299
|
-
<a:accent6><a:srgbClr val="${c.accent6}"/></a:accent6>
|
|
300
|
-
<a:hlink><a:srgbClr val="${c.hlink}"/></a:hlink>
|
|
301
|
-
<a:folHlink><a:srgbClr val="${c.folHlink}"/></a:folHlink>
|
|
302
|
-
</a:clrScheme>
|
|
303
|
-
<a:fontScheme name="${theme.name}">
|
|
304
|
-
<a:majorFont>
|
|
305
|
-
<a:latin typeface="${f.major}"/>
|
|
306
|
-
<a:ea typeface=""/>
|
|
307
|
-
<a:cs typeface=""/>
|
|
308
|
-
</a:majorFont>
|
|
309
|
-
<a:minorFont>
|
|
310
|
-
<a:latin typeface="${f.minor}"/>
|
|
311
|
-
<a:ea typeface=""/>
|
|
312
|
-
<a:cs typeface=""/>
|
|
313
|
-
</a:minorFont>
|
|
314
|
-
</a:fontScheme>
|
|
315
|
-
<a:fmtScheme name="${theme.name}">
|
|
316
|
-
<a:fillStyleLst>
|
|
317
|
-
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
|
318
|
-
<a:gradFill rotWithShape="1">
|
|
319
|
-
<a:gsLst>
|
|
320
|
-
<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs>
|
|
321
|
-
<a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs>
|
|
322
|
-
<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs>
|
|
323
|
-
</a:gsLst>
|
|
324
|
-
<a:lin ang="16200000" scaled="1"/>
|
|
325
|
-
</a:gradFill>
|
|
326
|
-
<a:gradFill rotWithShape="1">
|
|
327
|
-
<a:gsLst>
|
|
328
|
-
<a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs>
|
|
329
|
-
<a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs>
|
|
330
|
-
<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs>
|
|
331
|
-
</a:gsLst>
|
|
332
|
-
<a:lin ang="16200000" scaled="0"/>
|
|
333
|
-
</a:gradFill>
|
|
334
|
-
</a:fillStyleLst>
|
|
335
|
-
<a:lnStyleLst>
|
|
336
|
-
<a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln>
|
|
337
|
-
<a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>
|
|
338
|
-
<a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>
|
|
339
|
-
</a:lnStyleLst>
|
|
340
|
-
<a:effectStyleLst>
|
|
341
|
-
<a:effectStyle><a:effectLst/></a:effectStyle>
|
|
342
|
-
<a:effectStyle><a:effectLst/></a:effectStyle>
|
|
343
|
-
<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle>
|
|
344
|
-
</a:effectStyleLst>
|
|
345
|
-
<a:bgFillStyleLst>
|
|
346
|
-
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
|
347
|
-
<a:gradFill rotWithShape="1">
|
|
348
|
-
<a:gsLst>
|
|
349
|
-
<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs>
|
|
350
|
-
<a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs>
|
|
351
|
-
<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs>
|
|
352
|
-
</a:gsLst>
|
|
353
|
-
<a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path>
|
|
354
|
-
</a:gradFill>
|
|
355
|
-
<a:gradFill rotWithShape="1">
|
|
356
|
-
<a:gsLst>
|
|
357
|
-
<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs>
|
|
358
|
-
<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs>
|
|
359
|
-
</a:gsLst>
|
|
360
|
-
<a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path>
|
|
361
|
-
</a:gradFill>
|
|
362
|
-
</a:bgFillStyleLst>
|
|
363
|
-
</a:fmtScheme>
|
|
364
|
-
</a:themeElements>
|
|
365
|
-
<a:objectDefaults/>
|
|
366
|
-
<a:extraClrSchemeLst/>
|
|
367
|
-
</a:theme>`;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Get pandoc's default reference.pptx as a base template
|
|
372
|
-
*/
|
|
373
|
-
function getPandocReferenceTemplate(): Buffer {
|
|
374
|
-
try {
|
|
375
|
-
// Use pandoc to extract the default reference template
|
|
376
|
-
const result = execSync('pandoc --print-default-data-file reference.pptx', {
|
|
377
|
-
encoding: 'buffer',
|
|
378
|
-
maxBuffer: 1024 * 1024, // 1MB should be plenty
|
|
379
|
-
});
|
|
380
|
-
return result;
|
|
381
|
-
} catch (err: unknown) {
|
|
382
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
383
|
-
throw new Error(`Failed to get pandoc reference template: ${message}`);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Generate a PPTX theme file by modifying pandoc's reference template
|
|
389
|
-
*/
|
|
390
|
-
export function generateThemeFile(themeName: string, outputPath: string): string {
|
|
391
|
-
const theme = PPTX_THEMES[themeName];
|
|
392
|
-
if (!theme) {
|
|
393
|
-
throw new Error(`Unknown theme: ${themeName}`);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// Get pandoc's reference template as base
|
|
397
|
-
const templateBuffer = getPandocReferenceTemplate();
|
|
398
|
-
const zip = new AdmZip(templateBuffer);
|
|
399
|
-
|
|
400
|
-
// Replace theme.xml with our custom theme
|
|
401
|
-
zip.updateFile('ppt/theme/theme1.xml', Buffer.from(generateTheme(theme), 'utf-8'));
|
|
402
|
-
|
|
403
|
-
// For dark themes, update slide masters and layouts with background color
|
|
404
|
-
if (theme.background) {
|
|
405
|
-
updateBackgroundColor(zip, theme.background);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// Ensure output directory exists
|
|
409
|
-
const dir = dirname(outputPath);
|
|
410
|
-
if (!existsSync(dir)) {
|
|
411
|
-
mkdirSync(dir, { recursive: true });
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
zip.writeZip(outputPath);
|
|
415
|
-
return outputPath;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Update background color in slide masters and layouts for dark themes
|
|
420
|
-
*/
|
|
421
|
-
function updateBackgroundColor(zip: AdmZip, bgColor: string): void {
|
|
422
|
-
const entries = zip.getEntries();
|
|
423
|
-
|
|
424
|
-
for (const entry of entries) {
|
|
425
|
-
const name = entry.entryName;
|
|
426
|
-
|
|
427
|
-
// Update slide masters and layouts
|
|
428
|
-
if (name.includes('slideMasters/') || name.includes('slideLayouts/')) {
|
|
429
|
-
if (name.endsWith('.xml') && !name.includes('_rels')) {
|
|
430
|
-
let content = entry.getData().toString('utf-8');
|
|
431
|
-
|
|
432
|
-
// Replace light background with dark background
|
|
433
|
-
// Look for <a:schemeClr val="lt1"/> in bgPr and replace
|
|
434
|
-
content = content.replace(
|
|
435
|
-
/<p:bg>[\s\S]*?<\/p:bg>/g,
|
|
436
|
-
`<p:bg><p:bgPr><a:solidFill><a:srgbClr val="${bgColor}"/></a:solidFill><a:effectLst/></p:bgPr></p:bg>`
|
|
437
|
-
);
|
|
438
|
-
|
|
439
|
-
zip.updateFile(name, Buffer.from(content, 'utf-8'));
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Get path to bundled theme file, generating if needed
|
|
447
|
-
*/
|
|
448
|
-
export function getThemePath(themeName: string): string | null {
|
|
449
|
-
if (!PPTX_THEMES[themeName]) {
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
const themesDir = join(__dirname, 'pptx-themes');
|
|
454
|
-
const themePath = join(themesDir, `${themeName}.pptx`);
|
|
455
|
-
|
|
456
|
-
// Generate if doesn't exist
|
|
457
|
-
if (!existsSync(themePath)) {
|
|
458
|
-
if (!existsSync(themesDir)) {
|
|
459
|
-
mkdirSync(themesDir, { recursive: true });
|
|
460
|
-
}
|
|
461
|
-
generateThemeFile(themeName, themePath);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
return themePath;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Generate all theme files
|
|
469
|
-
*/
|
|
470
|
-
export function generateAllThemes(outputDir: string): Array<{ theme: string; path: string }> {
|
|
471
|
-
if (!existsSync(outputDir)) {
|
|
472
|
-
mkdirSync(outputDir, { recursive: true });
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const results = [];
|
|
476
|
-
for (const themeName of Object.keys(PPTX_THEMES)) {
|
|
477
|
-
const outputPath = join(outputDir, `${themeName}.pptx`);
|
|
478
|
-
generateThemeFile(themeName, outputPath);
|
|
479
|
-
results.push({ theme: themeName, path: outputPath });
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return results;
|
|
483
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* PPTX Theme System
|
|
3
|
+
*
|
|
4
|
+
* Provides 6 built-in themes for PPTX output, independent of Beamer themes.
|
|
5
|
+
* Each theme is a reference PPTX file that defines colors, fonts, and slide layouts.
|
|
6
|
+
*
|
|
7
|
+
* Uses pandoc's default reference.pptx as the base template and modifies the theme.xml
|
|
8
|
+
* to apply custom colors and fonts. This ensures all 11 required slide layouts are present.
|
|
9
|
+
*
|
|
10
|
+
* Themes:
|
|
11
|
+
* - default: Clean white with blue accents (professional)
|
|
12
|
+
* - dark: Dark background with light text (modern)
|
|
13
|
+
* - academic: Classic serif fonts, muted colors (scholarly)
|
|
14
|
+
* - minimal: High contrast black/white (clean)
|
|
15
|
+
* - corporate: Navy/gold color scheme (business)
|
|
16
|
+
* - plant: Nature-inspired green theme (ecology/biology)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import { join, dirname } from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
import { execSync } from 'node:child_process';
|
|
23
|
+
import AdmZip from 'adm-zip';
|
|
24
|
+
|
|
25
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Color scheme for a theme
|
|
29
|
+
*/
|
|
30
|
+
interface ThemeColors {
|
|
31
|
+
dk1: string;
|
|
32
|
+
lt1: string;
|
|
33
|
+
dk2: string;
|
|
34
|
+
lt2: string;
|
|
35
|
+
accent1: string;
|
|
36
|
+
accent2: string;
|
|
37
|
+
accent3: string;
|
|
38
|
+
accent4: string;
|
|
39
|
+
accent5: string;
|
|
40
|
+
accent6: string;
|
|
41
|
+
hlink: string;
|
|
42
|
+
folHlink: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Font scheme for a theme
|
|
47
|
+
*/
|
|
48
|
+
interface ThemeFonts {
|
|
49
|
+
major: string;
|
|
50
|
+
minor: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* PPTX theme definition
|
|
55
|
+
*/
|
|
56
|
+
interface PptxTheme {
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
colors: ThemeColors;
|
|
60
|
+
fonts: ThemeFonts;
|
|
61
|
+
background?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Theme definitions with colors and fonts
|
|
66
|
+
*/
|
|
67
|
+
export const PPTX_THEMES: Record<string, PptxTheme> = {
|
|
68
|
+
default: {
|
|
69
|
+
name: 'Default',
|
|
70
|
+
description: 'Clean white with blue accents',
|
|
71
|
+
colors: {
|
|
72
|
+
dk1: '000000', // Dark text
|
|
73
|
+
lt1: 'FFFFFF', // Light background
|
|
74
|
+
dk2: '1F497D', // Dark accent (navy)
|
|
75
|
+
lt2: 'EEECE1', // Light accent (cream)
|
|
76
|
+
accent1: '4472C4', // Blue
|
|
77
|
+
accent2: 'ED7D31', // Orange
|
|
78
|
+
accent3: 'A5A5A5', // Gray
|
|
79
|
+
accent4: 'FFC000', // Yellow
|
|
80
|
+
accent5: '5B9BD5', // Light blue
|
|
81
|
+
accent6: '70AD47', // Green
|
|
82
|
+
hlink: '0563C1', // Hyperlink blue
|
|
83
|
+
folHlink: '954F72', // Followed hyperlink
|
|
84
|
+
},
|
|
85
|
+
fonts: {
|
|
86
|
+
major: 'Calibri Light',
|
|
87
|
+
minor: 'Calibri',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
dark: {
|
|
91
|
+
name: 'Dark',
|
|
92
|
+
description: 'Dark background with light text',
|
|
93
|
+
colors: {
|
|
94
|
+
dk1: 'FFFFFF', // Light text (inverted)
|
|
95
|
+
lt1: '1E1E1E', // Dark background
|
|
96
|
+
dk2: 'E0E0E0', // Light gray
|
|
97
|
+
lt2: '2D2D2D', // Darker gray
|
|
98
|
+
accent1: '00B4D8', // Cyan
|
|
99
|
+
accent2: 'FF6B6B', // Coral
|
|
100
|
+
accent3: '95E1D3', // Mint
|
|
101
|
+
accent4: 'F38181', // Pink
|
|
102
|
+
accent5: 'AA96DA', // Lavender
|
|
103
|
+
accent6: 'FCBAD3', // Light pink
|
|
104
|
+
hlink: '00B4D8',
|
|
105
|
+
folHlink: 'AA96DA',
|
|
106
|
+
},
|
|
107
|
+
fonts: {
|
|
108
|
+
major: 'Inter',
|
|
109
|
+
minor: 'Inter',
|
|
110
|
+
},
|
|
111
|
+
background: '1E1E1E',
|
|
112
|
+
},
|
|
113
|
+
academic: {
|
|
114
|
+
name: 'Academic',
|
|
115
|
+
description: 'Classic serif fonts, muted colors',
|
|
116
|
+
colors: {
|
|
117
|
+
dk1: '2C3E50', // Dark blue-gray
|
|
118
|
+
lt1: 'FFFEF9', // Warm white
|
|
119
|
+
dk2: '34495E', // Slate
|
|
120
|
+
lt2: 'F5F5DC', // Beige
|
|
121
|
+
accent1: '8B4513', // Saddle brown
|
|
122
|
+
accent2: '2E8B57', // Sea green
|
|
123
|
+
accent3: '708090', // Slate gray
|
|
124
|
+
accent4: 'B8860B', // Dark goldenrod
|
|
125
|
+
accent5: '4682B4', // Steel blue
|
|
126
|
+
accent6: '6B8E23', // Olive drab
|
|
127
|
+
hlink: '8B4513',
|
|
128
|
+
folHlink: '708090',
|
|
129
|
+
},
|
|
130
|
+
fonts: {
|
|
131
|
+
major: 'Georgia',
|
|
132
|
+
minor: 'Palatino Linotype',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
minimal: {
|
|
136
|
+
name: 'Minimal',
|
|
137
|
+
description: 'High contrast black and white',
|
|
138
|
+
colors: {
|
|
139
|
+
dk1: '000000', // Pure black
|
|
140
|
+
lt1: 'FFFFFF', // Pure white
|
|
141
|
+
dk2: '333333', // Dark gray
|
|
142
|
+
lt2: 'F0F0F0', // Light gray
|
|
143
|
+
accent1: '000000', // Black accent
|
|
144
|
+
accent2: '666666', // Medium gray
|
|
145
|
+
accent3: '999999', // Light gray
|
|
146
|
+
accent4: 'CCCCCC', // Lighter gray
|
|
147
|
+
accent5: '333333', // Dark gray
|
|
148
|
+
accent6: '4D4D4D', // Charcoal
|
|
149
|
+
hlink: '000000',
|
|
150
|
+
folHlink: '666666',
|
|
151
|
+
},
|
|
152
|
+
fonts: {
|
|
153
|
+
major: 'Roboto Light',
|
|
154
|
+
minor: 'Roboto',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
corporate: {
|
|
158
|
+
name: 'Corporate',
|
|
159
|
+
description: 'Navy and gold professional theme',
|
|
160
|
+
colors: {
|
|
161
|
+
dk1: '0D1B2A', // Very dark navy
|
|
162
|
+
lt1: 'FFFFFF', // White
|
|
163
|
+
dk2: '1B263B', // Dark navy
|
|
164
|
+
lt2: 'E0E1DD', // Light gray
|
|
165
|
+
accent1: 'D4AF37', // Gold
|
|
166
|
+
accent2: '415A77', // Steel blue
|
|
167
|
+
accent3: '778DA9', // Light steel
|
|
168
|
+
accent4: 'C5A900', // Darker gold
|
|
169
|
+
accent5: '1B4965', // Deep blue
|
|
170
|
+
accent6: '5FA8D3', // Sky blue
|
|
171
|
+
hlink: 'D4AF37',
|
|
172
|
+
folHlink: '778DA9',
|
|
173
|
+
},
|
|
174
|
+
fonts: {
|
|
175
|
+
major: 'Garamond',
|
|
176
|
+
minor: 'Garamond',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
plant: {
|
|
180
|
+
name: 'Plant',
|
|
181
|
+
description: 'Nature-inspired green theme for ecology/biology',
|
|
182
|
+
colors: {
|
|
183
|
+
dk1: '2D4A22', // Dark forest green
|
|
184
|
+
lt1: 'FFFFFF', // White
|
|
185
|
+
dk2: '3D5A2E', // Medium forest
|
|
186
|
+
lt2: 'F5F7F2', // Light sage
|
|
187
|
+
accent1: '608C32', // Primary green (theme accent)
|
|
188
|
+
accent2: '8B4513', // Earth brown
|
|
189
|
+
accent3: '888888', // Gray (for buildup)
|
|
190
|
+
accent4: '7CB342', // Light green
|
|
191
|
+
accent5: '4A6B3A', // Olive green
|
|
192
|
+
accent6: 'A5D6A7', // Pale green
|
|
193
|
+
hlink: '608C32',
|
|
194
|
+
folHlink: '4A6B3A',
|
|
195
|
+
},
|
|
196
|
+
fonts: {
|
|
197
|
+
major: 'Aptos Display',
|
|
198
|
+
minor: 'Aptos',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get list of available theme names
|
|
205
|
+
*/
|
|
206
|
+
export function getThemeNames(): string[] {
|
|
207
|
+
return Object.keys(PPTX_THEMES);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Get theme definition by name
|
|
212
|
+
*/
|
|
213
|
+
export function getTheme(name: string): PptxTheme | null {
|
|
214
|
+
return PPTX_THEMES[name] || null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Generate [Content_Types].xml
|
|
219
|
+
*/
|
|
220
|
+
function generateContentTypes(): string {
|
|
221
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
222
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
223
|
+
<Default Extension="jpeg" ContentType="image/jpeg"/>
|
|
224
|
+
<Default Extension="png" ContentType="image/png"/>
|
|
225
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
226
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
227
|
+
<Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>
|
|
228
|
+
<Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/>
|
|
229
|
+
<Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
|
|
230
|
+
<Override PartName="/ppt/slideLayouts/slideLayout2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/>
|
|
231
|
+
<Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
|
|
232
|
+
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
|
|
233
|
+
<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
|
|
234
|
+
</Types>`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Generate _rels/.rels
|
|
239
|
+
*/
|
|
240
|
+
function generateRels(): string {
|
|
241
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
242
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
243
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="ppt/presentation.xml"/>
|
|
244
|
+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
|
|
245
|
+
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
|
|
246
|
+
</Relationships>`;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Generate ppt/_rels/presentation.xml.rels
|
|
251
|
+
*/
|
|
252
|
+
function generatePresentationRels(): string {
|
|
253
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
254
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
255
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>
|
|
256
|
+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
|
|
257
|
+
</Relationships>`;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Generate ppt/presentation.xml
|
|
262
|
+
*/
|
|
263
|
+
function generatePresentation(): string {
|
|
264
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
265
|
+
<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" saveSubsetFonts="1">
|
|
266
|
+
<p:sldMasterIdLst>
|
|
267
|
+
<p:sldMasterId id="2147483648" r:id="rId1"/>
|
|
268
|
+
</p:sldMasterIdLst>
|
|
269
|
+
<p:sldSz cx="12192000" cy="6858000"/>
|
|
270
|
+
<p:notesSz cx="6858000" cy="9144000"/>
|
|
271
|
+
<p:defaultTextStyle>
|
|
272
|
+
<a:defPPr>
|
|
273
|
+
<a:defRPr lang="en-US"/>
|
|
274
|
+
</a:defPPr>
|
|
275
|
+
</p:defaultTextStyle>
|
|
276
|
+
</p:presentation>`;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Generate ppt/theme/theme1.xml with theme colors and fonts
|
|
281
|
+
*/
|
|
282
|
+
function generateTheme(theme: PptxTheme): string {
|
|
283
|
+
const c = theme.colors;
|
|
284
|
+
const f = theme.fonts;
|
|
285
|
+
|
|
286
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
287
|
+
<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${theme.name}">
|
|
288
|
+
<a:themeElements>
|
|
289
|
+
<a:clrScheme name="${theme.name}">
|
|
290
|
+
<a:dk1><a:srgbClr val="${c.dk1}"/></a:dk1>
|
|
291
|
+
<a:lt1><a:srgbClr val="${c.lt1}"/></a:lt1>
|
|
292
|
+
<a:dk2><a:srgbClr val="${c.dk2}"/></a:dk2>
|
|
293
|
+
<a:lt2><a:srgbClr val="${c.lt2}"/></a:lt2>
|
|
294
|
+
<a:accent1><a:srgbClr val="${c.accent1}"/></a:accent1>
|
|
295
|
+
<a:accent2><a:srgbClr val="${c.accent2}"/></a:accent2>
|
|
296
|
+
<a:accent3><a:srgbClr val="${c.accent3}"/></a:accent3>
|
|
297
|
+
<a:accent4><a:srgbClr val="${c.accent4}"/></a:accent4>
|
|
298
|
+
<a:accent5><a:srgbClr val="${c.accent5}"/></a:accent5>
|
|
299
|
+
<a:accent6><a:srgbClr val="${c.accent6}"/></a:accent6>
|
|
300
|
+
<a:hlink><a:srgbClr val="${c.hlink}"/></a:hlink>
|
|
301
|
+
<a:folHlink><a:srgbClr val="${c.folHlink}"/></a:folHlink>
|
|
302
|
+
</a:clrScheme>
|
|
303
|
+
<a:fontScheme name="${theme.name}">
|
|
304
|
+
<a:majorFont>
|
|
305
|
+
<a:latin typeface="${f.major}"/>
|
|
306
|
+
<a:ea typeface=""/>
|
|
307
|
+
<a:cs typeface=""/>
|
|
308
|
+
</a:majorFont>
|
|
309
|
+
<a:minorFont>
|
|
310
|
+
<a:latin typeface="${f.minor}"/>
|
|
311
|
+
<a:ea typeface=""/>
|
|
312
|
+
<a:cs typeface=""/>
|
|
313
|
+
</a:minorFont>
|
|
314
|
+
</a:fontScheme>
|
|
315
|
+
<a:fmtScheme name="${theme.name}">
|
|
316
|
+
<a:fillStyleLst>
|
|
317
|
+
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
|
318
|
+
<a:gradFill rotWithShape="1">
|
|
319
|
+
<a:gsLst>
|
|
320
|
+
<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs>
|
|
321
|
+
<a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs>
|
|
322
|
+
<a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs>
|
|
323
|
+
</a:gsLst>
|
|
324
|
+
<a:lin ang="16200000" scaled="1"/>
|
|
325
|
+
</a:gradFill>
|
|
326
|
+
<a:gradFill rotWithShape="1">
|
|
327
|
+
<a:gsLst>
|
|
328
|
+
<a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs>
|
|
329
|
+
<a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs>
|
|
330
|
+
<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs>
|
|
331
|
+
</a:gsLst>
|
|
332
|
+
<a:lin ang="16200000" scaled="0"/>
|
|
333
|
+
</a:gradFill>
|
|
334
|
+
</a:fillStyleLst>
|
|
335
|
+
<a:lnStyleLst>
|
|
336
|
+
<a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln>
|
|
337
|
+
<a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>
|
|
338
|
+
<a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln>
|
|
339
|
+
</a:lnStyleLst>
|
|
340
|
+
<a:effectStyleLst>
|
|
341
|
+
<a:effectStyle><a:effectLst/></a:effectStyle>
|
|
342
|
+
<a:effectStyle><a:effectLst/></a:effectStyle>
|
|
343
|
+
<a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle>
|
|
344
|
+
</a:effectStyleLst>
|
|
345
|
+
<a:bgFillStyleLst>
|
|
346
|
+
<a:solidFill><a:schemeClr val="phClr"/></a:solidFill>
|
|
347
|
+
<a:gradFill rotWithShape="1">
|
|
348
|
+
<a:gsLst>
|
|
349
|
+
<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs>
|
|
350
|
+
<a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs>
|
|
351
|
+
<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs>
|
|
352
|
+
</a:gsLst>
|
|
353
|
+
<a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path>
|
|
354
|
+
</a:gradFill>
|
|
355
|
+
<a:gradFill rotWithShape="1">
|
|
356
|
+
<a:gsLst>
|
|
357
|
+
<a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs>
|
|
358
|
+
<a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs>
|
|
359
|
+
</a:gsLst>
|
|
360
|
+
<a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path>
|
|
361
|
+
</a:gradFill>
|
|
362
|
+
</a:bgFillStyleLst>
|
|
363
|
+
</a:fmtScheme>
|
|
364
|
+
</a:themeElements>
|
|
365
|
+
<a:objectDefaults/>
|
|
366
|
+
<a:extraClrSchemeLst/>
|
|
367
|
+
</a:theme>`;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Get pandoc's default reference.pptx as a base template
|
|
372
|
+
*/
|
|
373
|
+
function getPandocReferenceTemplate(): Buffer {
|
|
374
|
+
try {
|
|
375
|
+
// Use pandoc to extract the default reference template
|
|
376
|
+
const result = execSync('pandoc --print-default-data-file reference.pptx', {
|
|
377
|
+
encoding: 'buffer',
|
|
378
|
+
maxBuffer: 1024 * 1024, // 1MB should be plenty
|
|
379
|
+
});
|
|
380
|
+
return result;
|
|
381
|
+
} catch (err: unknown) {
|
|
382
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
383
|
+
throw new Error(`Failed to get pandoc reference template: ${message}`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Generate a PPTX theme file by modifying pandoc's reference template
|
|
389
|
+
*/
|
|
390
|
+
export function generateThemeFile(themeName: string, outputPath: string): string {
|
|
391
|
+
const theme = PPTX_THEMES[themeName];
|
|
392
|
+
if (!theme) {
|
|
393
|
+
throw new Error(`Unknown theme: ${themeName}`);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Get pandoc's reference template as base
|
|
397
|
+
const templateBuffer = getPandocReferenceTemplate();
|
|
398
|
+
const zip = new AdmZip(templateBuffer);
|
|
399
|
+
|
|
400
|
+
// Replace theme.xml with our custom theme
|
|
401
|
+
zip.updateFile('ppt/theme/theme1.xml', Buffer.from(generateTheme(theme), 'utf-8'));
|
|
402
|
+
|
|
403
|
+
// For dark themes, update slide masters and layouts with background color
|
|
404
|
+
if (theme.background) {
|
|
405
|
+
updateBackgroundColor(zip, theme.background);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Ensure output directory exists
|
|
409
|
+
const dir = dirname(outputPath);
|
|
410
|
+
if (!existsSync(dir)) {
|
|
411
|
+
mkdirSync(dir, { recursive: true });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
zip.writeZip(outputPath);
|
|
415
|
+
return outputPath;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Update background color in slide masters and layouts for dark themes
|
|
420
|
+
*/
|
|
421
|
+
function updateBackgroundColor(zip: AdmZip, bgColor: string): void {
|
|
422
|
+
const entries = zip.getEntries();
|
|
423
|
+
|
|
424
|
+
for (const entry of entries) {
|
|
425
|
+
const name = entry.entryName;
|
|
426
|
+
|
|
427
|
+
// Update slide masters and layouts
|
|
428
|
+
if (name.includes('slideMasters/') || name.includes('slideLayouts/')) {
|
|
429
|
+
if (name.endsWith('.xml') && !name.includes('_rels')) {
|
|
430
|
+
let content = entry.getData().toString('utf-8');
|
|
431
|
+
|
|
432
|
+
// Replace light background with dark background
|
|
433
|
+
// Look for <a:schemeClr val="lt1"/> in bgPr and replace
|
|
434
|
+
content = content.replace(
|
|
435
|
+
/<p:bg>[\s\S]*?<\/p:bg>/g,
|
|
436
|
+
`<p:bg><p:bgPr><a:solidFill><a:srgbClr val="${bgColor}"/></a:solidFill><a:effectLst/></p:bgPr></p:bg>`
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
zip.updateFile(name, Buffer.from(content, 'utf-8'));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Get path to bundled theme file, generating if needed
|
|
447
|
+
*/
|
|
448
|
+
export function getThemePath(themeName: string): string | null {
|
|
449
|
+
if (!PPTX_THEMES[themeName]) {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const themesDir = join(__dirname, 'pptx-themes');
|
|
454
|
+
const themePath = join(themesDir, `${themeName}.pptx`);
|
|
455
|
+
|
|
456
|
+
// Generate if doesn't exist
|
|
457
|
+
if (!existsSync(themePath)) {
|
|
458
|
+
if (!existsSync(themesDir)) {
|
|
459
|
+
mkdirSync(themesDir, { recursive: true });
|
|
460
|
+
}
|
|
461
|
+
generateThemeFile(themeName, themePath);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return themePath;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Generate all theme files
|
|
469
|
+
*/
|
|
470
|
+
export function generateAllThemes(outputDir: string): Array<{ theme: string; path: string }> {
|
|
471
|
+
if (!existsSync(outputDir)) {
|
|
472
|
+
mkdirSync(outputDir, { recursive: true });
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const results = [];
|
|
476
|
+
for (const themeName of Object.keys(PPTX_THEMES)) {
|
|
477
|
+
const outputPath = join(outputDir, `${themeName}.pptx`);
|
|
478
|
+
generateThemeFile(themeName, outputPath);
|
|
479
|
+
results.push({ theme: themeName, path: outputPath });
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return results;
|
|
483
|
+
}
|