@tolokoban/impress 0.0.0-stage → 0.1.0

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/dist/styles.js ADDED
@@ -0,0 +1,411 @@
1
+ /**
2
+ * Default Impress styles used by `impress.ts`.
3
+ *
4
+ * Every visible element of the generated slides references one of the
5
+ * styles defined here, so they can also be tweaked afterwards in
6
+ * LibreOffice (Styles sidebar: "Drawing Styles" and "Presentation Styles").
7
+ *
8
+ * For each `foo.md`, `impress.ts` writes these defaults to `foo.style.json`
9
+ * if it does not exist yet; otherwise that file is merged over the defaults.
10
+ *
11
+ * Property keys are ODF attribute names (`fo:font-size`, `draw:fill-color`, ...).
12
+ * Values can reference the theme with placeholders: "{colors.primary}",
13
+ * "{sizes.title}pt", "{colors.grid.0.1}"...
14
+ */
15
+ export const defaultTheme = {
16
+ colors: {
17
+ primary: "#1F3A5F",
18
+ accent: "#E8833A",
19
+ ink: "#222222",
20
+ muted: "#7A8899",
21
+ subtitle: "#FFD8B0",
22
+ white: "#FFFFFF",
23
+ quoteBackground: "#F1F4F8",
24
+ promptBackground: "#DCEBFF",
25
+ promptInk: "#0B2545",
26
+ codeBackground: "#F3F3F3",
27
+ tableBorder: "#C9D3DF",
28
+ tableBand: "#EEF2F7",
29
+ gridBackground: "#F7F7F7",
30
+ graphNode: "#EAF1FB",
31
+ graphCluster: "#F5F7FA",
32
+ /** One color per cell of a 2×2 grid: [background, text]. */
33
+ grid: [
34
+ ["#C0392B", "#FFFFFF"],
35
+ ["#E67E22", "#FFFFFF"],
36
+ ["#F1C40F", "#222222"],
37
+ ["#27AE60", "#FFFFFF"],
38
+ ],
39
+ },
40
+ fonts: {
41
+ sans: "'Liberation Sans'",
42
+ mono: "'DejaVu Sans Mono'",
43
+ },
44
+ /** Font sizes in points. They are also used to estimate text heights. */
45
+ sizes: {
46
+ title: 34,
47
+ sectionTitle: 44,
48
+ subtitle: 20,
49
+ breadcrumb: 14,
50
+ text: 24,
51
+ list: [24, 21, 18, 18, 18, 18, 18, 18, 18],
52
+ quote: 24,
53
+ prompt: 20,
54
+ code: 14,
55
+ table: 18,
56
+ tableSmall: 11,
57
+ columnTitle: 16,
58
+ columnText: 16,
59
+ gridTitle: 16,
60
+ gridText: 12,
61
+ notes: 14,
62
+ graphText: 14,
63
+ graphEdgeText: 12,
64
+ },
65
+ /** Geometry in cm (16:9 slide). */
66
+ slide: { width: 28, height: 15.75 },
67
+ content: { x: 1.2, y: 3.0, width: 25.6, height: 11.9, gap: 0.3 },
68
+ /** `@graph` diagrams. */
69
+ graph: {
70
+ /** Connector kind for edges: "curve", "line", "standard" (elbows) or "lines". */
71
+ connector: "curve",
72
+ /** Maximum enlargement of a diagram relative to its Graphviz size. */
73
+ maxScale: 1.5,
74
+ },
75
+ };
76
+ const sans = { "fo:font-family": "{fonts.sans}", "style:font-family-generic": "swiss" };
77
+ const mono = { "fo:font-family": "{fonts.mono}", "style:font-family-generic": "modern" };
78
+ /** Text that does not fit in its box is shrunk instead of overflowing. */
79
+ const shrink = {
80
+ "draw:auto-grow-height": "false",
81
+ "draw:auto-grow-width": "false",
82
+ "draw:fit-to-size": "false",
83
+ "style:shrink-to-fit": "true",
84
+ };
85
+ const bullets = {
86
+ chars: ["●", "–", "●", "–", "●", "–", "●", "–", "●"],
87
+ color: "{colors.accent}",
88
+ indent: 0.9,
89
+ size: "80%",
90
+ };
91
+ function masterStyles(master) {
92
+ const isSection = master === "Section";
93
+ const styles = {
94
+ [`${master}-title`]: {
95
+ family: "presentation",
96
+ graphic: { "draw:stroke": "none", "draw:fill": "none", "draw:textarea-vertical-align": "middle", ...shrink },
97
+ paragraph: { "fo:text-align": isSection ? "center" : "start" },
98
+ text: {
99
+ ...sans,
100
+ "fo:font-size": isSection ? "{sizes.sectionTitle}pt" : "{sizes.title}pt",
101
+ "fo:font-weight": "bold",
102
+ "fo:color": isSection ? "{colors.white}" : "{colors.primary}",
103
+ },
104
+ },
105
+ [`${master}-subtitle`]: {
106
+ family: "presentation",
107
+ graphic: { "draw:stroke": "none", "draw:fill": "none", "draw:textarea-vertical-align": "top", ...shrink },
108
+ paragraph: { "fo:text-align": "center" },
109
+ text: { ...sans, "fo:font-size": "{sizes.subtitle}pt", "fo:color": "{colors.subtitle}" },
110
+ },
111
+ [`${master}-outline1`]: {
112
+ family: "presentation",
113
+ graphic: { "draw:stroke": "none", "draw:fill": "none", "draw:textarea-vertical-align": "top", ...shrink },
114
+ paragraph: { "fo:margin-top": "0.1cm", "fo:margin-bottom": "0.15cm", "fo:line-height": "105%" },
115
+ text: { ...sans, "fo:font-size": "{sizes.list.0}pt", "fo:color": "{colors.ink}" },
116
+ bullets,
117
+ },
118
+ };
119
+ for (let level = 2; level <= 9; level++) {
120
+ styles[`${master}-outline${level}`] = {
121
+ family: "presentation",
122
+ parent: `${master}-outline${level - 1}`,
123
+ paragraph: { "fo:margin-top": "0.05cm", "fo:margin-bottom": "0.1cm" },
124
+ text: { "fo:font-size": `{sizes.list.${level - 1}}pt` },
125
+ };
126
+ }
127
+ styles[`${master}-notes`] = {
128
+ family: "presentation",
129
+ graphic: { "draw:stroke": "none", "draw:fill": "none" },
130
+ paragraph: { "fo:margin-bottom": "0.2cm" },
131
+ text: { ...sans, "fo:font-size": "{sizes.notes}pt", "fo:color": "{colors.ink}" },
132
+ };
133
+ styles[`${master}-background`] = { family: "presentation", graphic: { "draw:stroke": "none", "draw:fill": "none" } };
134
+ styles[`${master}-backgroundobjects`] = { family: "presentation", graphic: { "draw:shadow": "hidden" } };
135
+ return styles;
136
+ }
137
+ function cellStyle(fill, color, bold, size) {
138
+ return {
139
+ family: "table-cell",
140
+ graphic: {
141
+ "draw:fill": "solid",
142
+ "draw:fill-color": fill,
143
+ "draw:textarea-vertical-align": "middle",
144
+ "fo:padding-left": "0.2cm",
145
+ "fo:padding-right": "0.2cm",
146
+ "fo:padding-top": "0.1cm",
147
+ "fo:padding-bottom": "0.1cm",
148
+ },
149
+ paragraph: { "fo:text-align": "start", "fo:border": "0.03cm solid {colors.tableBorder}" },
150
+ text: { ...sans, "fo:font-size": size, "fo:color": color, ...(bold ? { "fo:font-weight": "bold" } : {}) },
151
+ };
152
+ }
153
+ function tableStyles(prefix, size) {
154
+ return {
155
+ [`${prefix}-entete`]: cellStyle("{colors.primary}", "{colors.white}", true, size),
156
+ [`${prefix}-cellule`]: cellStyle("{colors.white}", "{colors.ink}", false, size),
157
+ [`${prefix}-cellule-alt`]: cellStyle("{colors.tableBand}", "{colors.ink}", false, size),
158
+ };
159
+ }
160
+ function gridStyles() {
161
+ const styles = {};
162
+ defaultTheme.colors.grid.forEach((_, i) => {
163
+ styles[`Grille-titre-${i + 1}`] = {
164
+ family: "graphic",
165
+ parent: "Grille-titre",
166
+ graphic: { "draw:fill-color": `{colors.grid.${i}.0}` },
167
+ text: { "fo:color": `{colors.grid.${i}.1}` },
168
+ };
169
+ styles[`Grille-texte-${i + 1}`] = {
170
+ family: "graphic",
171
+ parent: "Grille-texte",
172
+ graphic: { "svg:stroke-color": `{colors.grid.${i}.0}` },
173
+ };
174
+ });
175
+ return styles;
176
+ }
177
+ const defaultStyles = {
178
+ standard: {
179
+ family: "graphic",
180
+ graphic: {
181
+ "draw:stroke": "none",
182
+ "draw:fill": "none",
183
+ "fo:padding-top": "0.1cm",
184
+ "fo:padding-bottom": "0.1cm",
185
+ "fo:padding-left": "0.15cm",
186
+ "fo:padding-right": "0.15cm",
187
+ "draw:textarea-vertical-align": "top",
188
+ },
189
+ paragraph: { "fo:margin-top": "0cm", "fo:margin-bottom": "0cm" },
190
+ text: { ...sans, "fo:font-size": "18pt", "fo:color": "{colors.ink}" },
191
+ },
192
+ /** Plain paragraphs. */
193
+ Texte: {
194
+ family: "graphic",
195
+ parent: "standard",
196
+ graphic: shrink,
197
+ paragraph: { "fo:margin-bottom": "0.2cm", "fo:line-height": "110%" },
198
+ text: { "fo:font-size": "{sizes.text}pt" },
199
+ },
200
+ /** Path of parent headings, above the slide title. */
201
+ "Fil-ariane": {
202
+ family: "graphic",
203
+ parent: "standard",
204
+ graphic: shrink,
205
+ text: { "fo:font-size": "{sizes.breadcrumb}pt", "fo:color": "{colors.muted}" },
206
+ },
207
+ /** Blockquotes (`> ...`). */
208
+ Citation: {
209
+ family: "graphic",
210
+ parent: "standard",
211
+ graphic: {
212
+ ...shrink,
213
+ "draw:fill": "solid",
214
+ "draw:fill-color": "{colors.quoteBackground}",
215
+ "draw:stroke": "solid",
216
+ "svg:stroke-color": "{colors.primary}",
217
+ "svg:stroke-width": "0.03cm",
218
+ "fo:padding-left": "0.6cm",
219
+ "fo:padding-right": "0.6cm",
220
+ "fo:padding-top": "0.4cm",
221
+ "fo:padding-bottom": "0.4cm",
222
+ "draw:textarea-vertical-align": "middle",
223
+ },
224
+ paragraph: { "fo:line-height": "115%" },
225
+ text: { "fo:font-size": "{sizes.quote}pt", "fo:font-style": "italic", "fo:color": "{colors.primary}" },
226
+ },
227
+ /** Chat prompts (```prompt). */
228
+ Prompt: {
229
+ family: "graphic",
230
+ parent: "standard",
231
+ graphic: {
232
+ ...shrink,
233
+ "draw:fill": "solid",
234
+ "draw:fill-color": "{colors.promptBackground}",
235
+ "draw:stroke": "none",
236
+ "draw:shadow": "visible",
237
+ "draw:shadow-offset-x": "0.08cm",
238
+ "draw:shadow-offset-y": "0.08cm",
239
+ "draw:shadow-color": "{colors.muted}",
240
+ "draw:shadow-opacity": "35%",
241
+ "fo:padding-left": "0.5cm",
242
+ "fo:padding-right": "0.5cm",
243
+ "fo:padding-top": "0.35cm",
244
+ "fo:padding-bottom": "0.35cm",
245
+ "draw:textarea-vertical-align": "middle",
246
+ "draw:textarea-horizontal-align": "justify",
247
+ "fo:wrap-option": "wrap",
248
+ },
249
+ paragraph: { "fo:text-align": "start" },
250
+ text: { "fo:font-size": "{sizes.prompt}pt", "fo:color": "{colors.promptInk}" },
251
+ },
252
+ /** Other code blocks. */
253
+ Code: {
254
+ family: "graphic",
255
+ parent: "Prompt",
256
+ graphic: { "draw:fill-color": "{colors.codeBackground}" },
257
+ text: { ...mono, "fo:font-size": "{sizes.code}pt", "fo:color": "{colors.ink}" },
258
+ },
259
+ Image: { family: "graphic", parent: "standard", graphic: { "draw:stroke": "none", "draw:fill": "none" } },
260
+ "Tableau-cadre": { family: "graphic", parent: "standard", graphic: { "draw:stroke": "none", "draw:fill": "none" } },
261
+ /** `@layout columns ...`: column headings and column text. */
262
+ "Colonne-titre": {
263
+ family: "graphic",
264
+ parent: "standard",
265
+ graphic: { ...shrink, "draw:textarea-vertical-align": "bottom" },
266
+ paragraph: { "fo:text-align": "center" },
267
+ text: { "fo:font-size": "{sizes.columnTitle}pt", "fo:font-weight": "bold", "fo:color": "{colors.primary}" },
268
+ },
269
+ "Colonne-texte": {
270
+ family: "graphic",
271
+ parent: "standard",
272
+ graphic: shrink,
273
+ paragraph: { "fo:margin-bottom": "0.15cm" },
274
+ text: { "fo:font-size": "{sizes.columnText}pt" },
275
+ bullets,
276
+ },
277
+ /** `@layout grid ...`: cell headings and cell bodies, colored by position. */
278
+ "Grille-titre": {
279
+ family: "graphic",
280
+ parent: "standard",
281
+ graphic: { ...shrink, "draw:fill": "solid", "draw:textarea-vertical-align": "middle", "fo:padding-left": "0.3cm" },
282
+ text: { "fo:font-size": "{sizes.gridTitle}pt", "fo:font-weight": "bold" },
283
+ },
284
+ "Grille-texte": {
285
+ family: "graphic",
286
+ parent: "standard",
287
+ graphic: {
288
+ ...shrink,
289
+ "draw:fill": "solid",
290
+ "draw:fill-color": "{colors.gridBackground}",
291
+ "draw:stroke": "solid",
292
+ "svg:stroke-width": "0.04cm",
293
+ "fo:padding-left": "0.3cm",
294
+ "fo:padding-right": "0.3cm",
295
+ "fo:padding-top": "0.2cm",
296
+ },
297
+ paragraph: { "fo:margin-bottom": "0.12cm" },
298
+ text: { "fo:font-size": "{sizes.gridText}pt" },
299
+ bullets,
300
+ },
301
+ ...gridStyles(),
302
+ /** Master page decorations. */
303
+ "Section-fond": {
304
+ family: "graphic",
305
+ parent: "standard",
306
+ graphic: { "draw:fill": "solid", "draw:fill-color": "{colors.primary}", "draw:stroke": "none" },
307
+ },
308
+ Decor: {
309
+ family: "graphic",
310
+ parent: "standard",
311
+ graphic: { "draw:fill": "solid", "draw:fill-color": "{colors.accent}", "draw:stroke": "none" },
312
+ },
313
+ /** `@graph` diagrams: nodes, clusters and edges. */
314
+ "Graphe-noeud": {
315
+ family: "graphic",
316
+ parent: "standard",
317
+ graphic: {
318
+ ...shrink,
319
+ "draw:fill": "solid",
320
+ "draw:fill-color": "{colors.graphNode}",
321
+ "draw:stroke": "solid",
322
+ "svg:stroke-color": "{colors.primary}",
323
+ "svg:stroke-width": "0.03cm",
324
+ "draw:textarea-vertical-align": "middle",
325
+ "draw:textarea-horizontal-align": "center",
326
+ "fo:padding-left": "0.05cm",
327
+ "fo:padding-right": "0.05cm",
328
+ "fo:padding-top": "0.05cm",
329
+ "fo:padding-bottom": "0.05cm",
330
+ },
331
+ paragraph: { "fo:text-align": "center" },
332
+ text: { "fo:font-size": "{sizes.graphText}pt", "fo:color": "{colors.ink}" },
333
+ },
334
+ /** Nodes with `shape=plaintext` (or none). */
335
+ "Graphe-texte": {
336
+ family: "graphic",
337
+ parent: "Graphe-noeud",
338
+ graphic: { "draw:fill": "none", "draw:stroke": "none" },
339
+ },
340
+ /** Graph label (`graph [label=...]`). */
341
+ "Graphe-titre": {
342
+ family: "graphic",
343
+ parent: "Graphe-texte",
344
+ text: { "fo:font-weight": "bold", "fo:color": "{colors.primary}" },
345
+ },
346
+ "Graphe-groupe": {
347
+ family: "graphic",
348
+ parent: "standard",
349
+ graphic: {
350
+ "draw:fill": "solid",
351
+ "draw:fill-color": "{colors.graphCluster}",
352
+ "draw:stroke": "solid",
353
+ "svg:stroke-color": "{colors.muted}",
354
+ "svg:stroke-width": "0.02cm",
355
+ "draw:textarea-vertical-align": "top",
356
+ "draw:textarea-horizontal-align": "center",
357
+ "draw:auto-grow-height": "false",
358
+ },
359
+ paragraph: { "fo:text-align": "center" },
360
+ text: { "fo:font-size": "{sizes.graphEdgeText}pt", "fo:font-weight": "bold", "fo:color": "{colors.muted}" },
361
+ },
362
+ /** Edges without arrow (undirected graphs, `dir=none`). */
363
+ "Graphe-lien-simple": {
364
+ family: "graphic",
365
+ parent: "standard",
366
+ graphic: { "draw:stroke": "solid", "svg:stroke-color": "{colors.ink}", "svg:stroke-width": "0.03cm" },
367
+ text: { "fo:font-size": "{sizes.graphEdgeText}pt", "fo:color": "{colors.ink}" },
368
+ },
369
+ "Graphe-lien": {
370
+ family: "graphic",
371
+ parent: "Graphe-lien-simple",
372
+ graphic: { "draw:marker-end": "Fleche", "draw:marker-end-width": "0.3cm" },
373
+ },
374
+ /** Edges with `dir=both`. */
375
+ "Graphe-lien-double": {
376
+ family: "graphic",
377
+ parent: "Graphe-lien",
378
+ graphic: { "draw:marker-start": "Fleche", "draw:marker-start-width": "0.3cm" },
379
+ },
380
+ "Decor-ligne": {
381
+ family: "graphic",
382
+ parent: "standard",
383
+ graphic: { "draw:stroke": "solid", "svg:stroke-color": "{colors.primary}", "svg:stroke-width": "0.04cm" },
384
+ },
385
+ ...masterStyles("Greta"),
386
+ ...masterStyles("Section"),
387
+ ...tableStyles("Tableau", "{sizes.table}pt"),
388
+ ...tableStyles("Tableau-petit", "{sizes.tableSmall}pt"),
389
+ };
390
+ export const defaultStyle = {
391
+ theme: defaultTheme,
392
+ styles: defaultStyles,
393
+ tableTemplates: ["Tableau", "Tableau-petit"].map(prefix => ({
394
+ name: prefix,
395
+ header: `${prefix}-entete`,
396
+ body: `${prefix}-cellule`,
397
+ bandedRows: `${prefix}-cellule-alt`,
398
+ })),
399
+ markers: {
400
+ Fleche: { viewBox: "0 0 20 30", d: "M10 0l-10 30h20z" },
401
+ },
402
+ dashes: {
403
+ Tirets: { "draw:style": "rect", "draw:dots1": "1", "draw:dots1-length": "0.2cm", "draw:distance": "0.15cm" },
404
+ },
405
+ spanStyles: {
406
+ T_b: { "fo:font-weight": "bold" },
407
+ T_i: { "fo:font-style": "italic" },
408
+ T_bi: { "fo:font-weight": "bold", "fo:font-style": "italic" },
409
+ T_code: mono,
410
+ },
411
+ };
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
- "name": "@tolokoban/impress",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@tolokoban/impress",
3
+ "version": "0.1.0",
4
+ "description": "Convert teaching markdown files into LibreOffice Impress presentations (.odp)",
5
+ "type": "module",
6
+ "bin": {
7
+ "impress": "dist/impress.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "prebuild": "rm -rf dist",
14
+ "build": "tsc",
15
+ "check": "tsc --noEmit",
16
+ "prepack": "npm run build",
17
+ "pub": "npm publish --access public"
18
+ },
19
+ "engines": {
20
+ "node": ">=20.15"
21
+ },
22
+ "keywords": [
23
+ "markdown",
24
+ "libreoffice",
25
+ "impress",
26
+ "odp",
27
+ "presentation",
28
+ "slides",
29
+ "graphviz"
30
+ ],
31
+ "author": "Tolokoban",
32
+ "license": "GPL-3.0",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/tolokoban/impress.git"
36
+ },
37
+ "homepage": "https://github.com/tolokoban/impress#readme",
38
+ "bugs": {
39
+ "url": "https://github.com/tolokoban/impress/issues"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "dependencies": {
45
+ "@hpcc-js/wasm-graphviz": "1.30.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^24.19.2",
49
+ "typescript": "^7.0.2"
50
+ }
51
+ }