@tolokoban/impress 0.1.0 → 0.13.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/README.md +99 -30
- package/dist/impress.js +911 -407
- package/dist/styles.js +46 -71
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,11 +8,34 @@ npx @tolokoban/impress course.md [other.md ...]
|
|
|
8
8
|
|
|
9
9
|
Each `foo.md` produces `foo.odp` in the same folder. Run it without arguments to see the help.
|
|
10
10
|
|
|
11
|
+
`@graph` diagrams are laid out by the [Graphviz](https://graphviz.org/) `dot` tool. When a file uses `@graph` and `dot` is not installed, `impress` offers to install it with the package manager of the system:
|
|
12
|
+
|
|
13
|
+
| System | Command |
|
|
14
|
+
| --- | --- |
|
|
15
|
+
| Linux | `apt-get`, `dnf`, `yum`, `pacman`, `zypper`, `apk` or `brew` (with `sudo` when needed) |
|
|
16
|
+
| macOS | `brew install graphviz` or `sudo port install graphviz` |
|
|
17
|
+
| Windows | `winget install Graphviz.Graphviz`, `choco install graphviz` or `scoop install graphviz` |
|
|
18
|
+
|
|
19
|
+
Without a known package manager (or in a non-interactive shell), it prints how to install it instead, and the presentations using `@graph` fail.
|
|
20
|
+
|
|
21
|
+
Each time `dot` renders a diagram, the exact command is printed after a bold cyan `>`, so you can run it yourself to check the PNG:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
> /usr/bin/dot -Tpng -Gdpi=300 -Gbgcolor=transparent "-Gfontname=Liberation Sans" … diagram.dot
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
In a terminal, the output is colored: file names in bold, the example of AI prompt (printed when the files contain `@hint` pragmas) in cyan, and the questions waiting for an answer in bright yellow. Set the `NO_COLOR` environment variable (or redirect the output) to disable the colors.
|
|
28
|
+
|
|
11
29
|
## Slides
|
|
12
30
|
|
|
13
31
|
- `#` headings become section slides (blue background).
|
|
14
|
-
- Deeper headings become content slides, split over several slides when they are too long.
|
|
32
|
+
- Deeper headings become content slides, split over several slides when they are too long. A deeper heading with no content of its own, only sub-headings, gets a section slide too: its big title is still the `#` heading above it, and the deeper heading goes in the subtitle (e.g. `Possibilités`).
|
|
15
33
|
- Paragraphs, lists, tables, blockquotes and images are laid out automatically: images go beside or below the text depending on their shape.
|
|
34
|
+
- A table too long for one slide is first spread over two side-by-side tables on the same slide. If that is still too long, it is split over several slides. In both cases the header row is repeated on each part, and every part keeps the same column widths. Put `@compact` before the table to shrink it onto one slide instead (see [Pragmas](#pragmas)).
|
|
35
|
+
- Table cells can hold images, as HTML (`<img src="logos/claude.webp" alt="Claude" width="48" height="48">`) or markdown (``). Their pixel sizes assume a 16px font: a 48px image is 3 times as tall as the text of the table, and it shrinks with the text of a `@compact` table. With only `width` or `height`, the other one follows the shape of the image; with neither, the image is 2 lines tall. An image alone in its cell is centered, otherwise it comes before the text. Images too wide for their column are shrunk to fit.
|
|
36
|
+
- Every image embedded in the `.odp` (PNG, JPEG, SVG, `@graph` diagrams, background images) is converted to WebP, at quality 70 by default (see [`theme.images`](#themeimages)). The `.odp` stays light, and SVG files look in the slides as they do in a browser, since they are rasterized before LibreOffice sees them.
|
|
37
|
+
- Lists can be bulleted (`- item`, `* item`) or numbered (`1. item`, `1) item`), and the two can be nested in each other. A numbered list starts at the number of its first item (`4.` starts at 4); the number of each following item is computed, not read. Numbered items get numbers `1.`, then letters `a.` and roman numerals `i.` when nested (see [Numbers](#numbers)).
|
|
38
|
+
- Blockquotes (`> ...`) are shown in a bordered box with a soft blurred shadow.
|
|
16
39
|
- A code block whose language is `prompt` is shown as a chat bubble.
|
|
17
40
|
|
|
18
41
|
## Pragmas
|
|
@@ -26,7 +49,11 @@ At the start of a line in the `.md` file:
|
|
|
26
49
|
| `@hint <text>` | Instruction for an AI: stored verbatim in the `.odp` (alt-text of the slide title), never displayed. |
|
|
27
50
|
| `@layout grid <C>x<R>` | Put the next C×R sections (starting at the next heading) on one slide, in a grid. |
|
|
28
51
|
| `@layout columns <sizes>` | Put the next sections on one slide, in columns sized `1fr`, `2fr`… or `auto` (one size per section). |
|
|
29
|
-
| `@
|
|
52
|
+
| `@layout …` *(not followed by a heading)* | Put the next blocks of the section (paragraph, list, image, table…) on one slide, one block per cell, without cell headings. |
|
|
53
|
+
| `@graph <file.dot>` | Insert a Graphviz diagram (path relative to the `.md`), rendered by `dot -Tpng` (the same Cairo renderer as DOT viewers, so the diagram looks the same in the slides) and embedded in the `.odp` as a WebP image. The fonts, sizes and colors of the theme are inserted as `graph [...]`, `node [...]` and `edge [...]` defaults at the start of the graph, so every attribute set in the `.dot` file wins, including its own `node [...]` / `edge [...]` defaults. |
|
|
54
|
+
| `@next` | Start a new slide with the same title as the current one. If the next line is a heading (`#`, `##`…), that heading gives the new slide its title instead. |
|
|
55
|
+
| `@compact` | The next table of the section, if it is too long for one slide, has its text shrunk (down to 4pt) until it fits on one slide with the paragraph introducing it, instead of being split into two columns or over several slides. The words of the header are never cut: if one of them is too long for its column, the text is shrunk further, even when the table would fit at full size (a header cell of several words may still wrap between words). |
|
|
56
|
+
| `@reveal [C<columns>] [R<rows>]` | The rows of the next table appear one slide after the other: the first slide shows only the header, each following slide reveals one more row. The table keeps its final size and place from the first slide. `C` and `R` list the columns and the body rows (counted from 1, header excluded) that are always visible, as numbers and ranges: `@reveal C1,3 R1-4` always shows columns 1 and 3 and rows 1 to 4. Both are optional. The speaker notes are repeated on every slide of the sequence. A revealed table always stays on one slide, and its header words are never cut, as with `@compact`: if it is too long, its rows are first spread over two side-by-side tables, and if that is still too long, its text is shrunk, on one table or two side by side, whichever keeps the text bigger. A table inside an `@layout` is shown entirely. |
|
|
30
57
|
|
|
31
58
|
When some files contain `@hint`, the end of the output gives a ready-to-paste prompt asking an AI agent to apply them to the `.odp`.
|
|
32
59
|
|
|
@@ -137,7 +164,7 @@ Text boxes shrink their text when it does not fit (`style:shrink-to-fit`), so a
|
|
|
137
164
|
Geometry, in centimeters.
|
|
138
165
|
|
|
139
166
|
- `slide`: `width` and `height` of the slides (default 28 × 15.75, i.e. 16:9). For 4:3, use for instance 28 × 21 and adapt `content`.
|
|
140
|
-
- `content`: the area that receives the content of the slides, below the title: `x`, `y`, `width`, `height`, and the vertical `gap` between two blocks.
|
|
167
|
+
- `content`: the area that receives the content of the slides, below the title: `x`, `y`, `width`, `height`, and the vertical `gap` between two blocks. `align` places the content vertically in this area: `"top"` (default) or `"center"`. With `"center"`, a slide holding only a few bullets has them in the middle of the slide instead of at the top (a wide image under the text still fills the remaining height).
|
|
141
168
|
|
|
142
169
|
The title, the breadcrumb and the decorations of the master pages have fixed positions (title at 0.95 cm from the top, line at 2.7 cm), section slides assume a slide about 28 cm wide, and the slide background is always white (change it in LibreOffice with _Slide › Slide Properties › Background_ on each master slide).
|
|
143
170
|
|
|
@@ -145,12 +172,40 @@ The title, the breadcrumb and the decorations of the master pages have fixed pos
|
|
|
145
172
|
|
|
146
173
|
Options for `@graph` diagrams.
|
|
147
174
|
|
|
148
|
-
- `
|
|
149
|
-
- `
|
|
175
|
+
- `maxScale`: maximum enlargement of a diagram relative to its Graphviz size (default 1.5). Small diagrams are not blown up, so their text does not become huge.
|
|
176
|
+
- `dpi`: resolution of the PNG rendered by Graphviz (default 300). Do not set `dpi` in the `.dot` file: the size of the diagram on the slide is computed from this one.
|
|
177
|
+
|
|
178
|
+
#### `theme.images`
|
|
179
|
+
|
|
180
|
+
Every embedded image is stored as WebP.
|
|
181
|
+
|
|
182
|
+
- `quality`: WebP quality, from 0 to 100 (default 70).
|
|
183
|
+
- `maxSize`: longest side in pixels (default 3840): larger images are shrunk. SVG images are rasterized at this size.
|
|
184
|
+
|
|
185
|
+
A WebP image already within `maxSize` is embedded as is, so it does not lose quality twice.
|
|
186
|
+
|
|
187
|
+
#### `theme.backgrounds`
|
|
188
|
+
|
|
189
|
+
An image for each master page (`Master` for content slides, `Section` for section slides), drawn above the background color and below the decorations and the text.
|
|
190
|
+
|
|
191
|
+
- `image`: path relative to the markdown file, `""` (default) for no image.
|
|
192
|
+
- `fit`: `"stretch"` (default) fills the area, `"contain"` keeps the aspect ratio and centers the image in the area.
|
|
193
|
+
- `x`, `y`, `width`, `height`: the area in centimeters (default: the whole slide).
|
|
194
|
+
|
|
195
|
+
The look of the image comes from the `Master-image` and `Section-image` styles: `draw:image-opacity`, `draw:color-mode` (`standard`, `greyscale`, `mono` or `watermark`), `draw:luminance`, `draw:contrast`, `draw:gamma`, `draw:red`, `draw:green`, `draw:blue`...
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"theme": { "backgrounds": { "Section": { "image": "images/city.jpg" } } },
|
|
200
|
+
"styles": { "Section-image": { "graphic": { "draw:image-opacity": "25%", "draw:color-mode": "greyscale" } } }
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
LibreOffice ignores image adjustments inherited from a named style, so they are also written to an automatic style on each image: change them in `foo.style.json` rather than in LibreOffice's Styles sidebar.
|
|
150
205
|
|
|
151
206
|
### Placeholders
|
|
152
207
|
|
|
153
|
-
Any string value of `styles`, `spanStyles`, `markers`, `dashes` or `
|
|
208
|
+
Any string value of `styles`, `spanStyles`, `markers`, `dashes`, `bullets` or `numbers` can reference the theme with `{path}`, where `path` is a dot-separated path in `theme` (array indexes are numbers):
|
|
154
209
|
|
|
155
210
|
```json
|
|
156
211
|
"fo:color": "{colors.primary}"
|
|
@@ -184,18 +239,19 @@ Each entry of `styles` is one named style:
|
|
|
184
239
|
| `paragraph` | Properties of the paragraphs: alignment, margins, line height… |
|
|
185
240
|
| `text` | Properties of the characters: font, size, weight, style, color… |
|
|
186
241
|
| `bullets` | Bullets of lists (only for styles that hold lists, see below). |
|
|
242
|
+
| `numbers` | Numbers of numbered lists (only for styles that hold lists, see below). |
|
|
187
243
|
|
|
188
244
|
Since styles inherit from each other, changing a parent changes all its children. For instance every drawing style derives from `standard`, and `Code` derives from `Prompt`.
|
|
189
245
|
|
|
190
246
|
#### Where each style is used
|
|
191
247
|
|
|
192
|
-
**Content slides** (master page `
|
|
248
|
+
**Content slides** (master page `Master`):
|
|
193
249
|
|
|
194
250
|
| Style | Element |
|
|
195
251
|
| --- | --- |
|
|
196
|
-
| `
|
|
252
|
+
| `Master-title` | Slide title. |
|
|
197
253
|
| `Fil-ariane` | Breadcrumb (parent headings) above the title. |
|
|
198
|
-
| `
|
|
254
|
+
| `Master-outline1` … `Master-outline9` | Lists, one style per level (each level inherits from the previous one). |
|
|
199
255
|
| `Texte` | Paragraphs. |
|
|
200
256
|
| `Citation` | Blockquotes. |
|
|
201
257
|
| `Prompt` | ` ```prompt ` code blocks (chat bubbles). |
|
|
@@ -203,20 +259,22 @@ Since styles inherit from each other, changing a parent changes all its children
|
|
|
203
259
|
| `Image` | Frame of images. |
|
|
204
260
|
| `Tableau-cadre` | Frame around tables. |
|
|
205
261
|
| `Decor` | Vertical bar on the left of the slide. |
|
|
262
|
+
| `Master-image` | Background image (`theme.backgrounds.Master`). |
|
|
206
263
|
| `Decor-ligne` | Line under the title. |
|
|
207
|
-
| `
|
|
264
|
+
| `Master-notes` | Speaker notes. |
|
|
208
265
|
|
|
209
266
|
**Section slides** (master page `Section`, for `#` headings):
|
|
210
267
|
|
|
211
268
|
| Style | Element |
|
|
212
269
|
| --- | --- |
|
|
213
|
-
| `Section-title` | Title. |
|
|
214
|
-
| `Section-subtitle` | Breadcrumb under the title. |
|
|
270
|
+
| `Section-title` | Title: always the `#` heading. |
|
|
271
|
+
| `Section-subtitle` | Breadcrumb of the deeper headings, under the title. |
|
|
215
272
|
| `Section-fond` | Full-slide background rectangle. |
|
|
273
|
+
| `Section-image` | Background image (`theme.backgrounds.Section`), above `Section-fond`. |
|
|
216
274
|
| `Decor` | Horizontal bar under the title. |
|
|
217
275
|
| `Section-notes` | Speaker notes. |
|
|
218
276
|
|
|
219
|
-
`Section-outline1…9`, `
|
|
277
|
+
`Section-outline1…9`, `Master-subtitle`, `*-background` and `*-backgroundobjects` exist for LibreOffice's master pages but are not used by the generated content.
|
|
220
278
|
|
|
221
279
|
**Tables:**
|
|
222
280
|
|
|
@@ -233,19 +291,6 @@ Cell borders are a `paragraph` property (`fo:border`) and padding a `graphic` pr
|
|
|
233
291
|
|
|
234
292
|
**`@layout grid`:** `Grille-titre` and `Grille-texte` hold the common properties; `Grille-titre-1…4` and `Grille-texte-1…4` only add the colors of each cell, taken from `theme.colors.grid`.
|
|
235
293
|
|
|
236
|
-
**`@graph` diagrams:**
|
|
237
|
-
|
|
238
|
-
| Style | Element |
|
|
239
|
-
| --- | --- |
|
|
240
|
-
| `Graphe-noeud` | Nodes. |
|
|
241
|
-
| `Graphe-texte` | Nodes without border (`shape=plaintext`, `none`, `plain`, `underline` or `style=invis`). |
|
|
242
|
-
| `Graphe-titre` | Label of the graph (`graph [label="…"]`). |
|
|
243
|
-
| `Graphe-groupe` | Clusters (`subgraph cluster_…`). |
|
|
244
|
-
| `Graphe-lien` | Directed edges (arrow at the end). |
|
|
245
|
-
| `Graphe-lien-simple` | Edges without arrow (undirected graphs, `dir=none`). |
|
|
246
|
-
| `Graphe-lien-double` | Edges with `dir=both`. |
|
|
247
|
-
|
|
248
|
-
Colors and font sizes set in the `.dot` file (`color`, `fillcolor`, `fontcolor`, `fontsize`, `style=filled`, `style=dashed`…) win over the styles: they become automatic styles derived from the named ones.
|
|
249
294
|
|
|
250
295
|
#### Common properties
|
|
251
296
|
|
|
@@ -289,7 +334,7 @@ Two properties are on purpose on most text styles and are best kept: `style:shri
|
|
|
289
334
|
|
|
290
335
|
#### Bullets
|
|
291
336
|
|
|
292
|
-
Styles that hold lists (`
|
|
337
|
+
Styles that hold lists (`Master-outline1`, `Colonne-texte`, `Grille-texte`) have a `bullets` entry:
|
|
293
338
|
|
|
294
339
|
```json
|
|
295
340
|
"bullets": {
|
|
@@ -305,7 +350,31 @@ Styles that hold lists (`Greta-outline1`, `Colonne-texte`, `Grille-texte`) have
|
|
|
305
350
|
- `indent`: indentation added at each level, in cm (a number, not a string).
|
|
306
351
|
- `size`: size of the bullet relative to the text.
|
|
307
352
|
|
|
308
|
-
Nested list items use the level of `chars` matching their depth: `
|
|
353
|
+
Nested list items use the level of `chars` matching their depth: `Master-outline2…9` do not need a `bullets` entry of their own.
|
|
354
|
+
|
|
355
|
+
#### Numbers
|
|
356
|
+
|
|
357
|
+
The same styles have a `numbers` entry, used by numbered lists (`1. item`):
|
|
358
|
+
|
|
359
|
+
```json
|
|
360
|
+
"numbers": {
|
|
361
|
+
"formats": ["1", "a", "i", "1", "a", "i", "1", "a", "i"],
|
|
362
|
+
"suffix": ".",
|
|
363
|
+
"color": "{colors.accent}",
|
|
364
|
+
"size": "100%",
|
|
365
|
+
"weight": "bold",
|
|
366
|
+
"indent": 0.9,
|
|
367
|
+
"width": 0.9
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
- `formats`: numbering of each level, from 1 to 9: `"1"` (1, 2, 3…), `"a"` / `"A"` (letters), `"i"` / `"I"` (roman numerals).
|
|
372
|
+
- `suffix`: text after the number. It applies to every item, so `1)` in the markdown is shown as `1.` with the default suffix.
|
|
373
|
+
- `color`, `size`, `weight` (`"bold"` or `"normal"`): look of the numbers.
|
|
374
|
+
- `indent`: indentation added at each level, in cm.
|
|
375
|
+
- `width`: room left for the number before the text, in cm.
|
|
376
|
+
|
|
377
|
+
A list holding numbered items is written with two named list styles, `<style>-numbers` and `<style>-bullets` (e.g. `Master-outline1-numbers`), built from `numbers` and `bullets`, so bullets nested in a numbered list (and the reverse) keep their own look. Lists with bullets only keep using the bullets of the frame style. Styles that only inherit lists (`Grille-texte-1…4`) use the entries of their parent.
|
|
309
378
|
|
|
310
379
|
### Table templates
|
|
311
380
|
|
|
@@ -364,7 +433,7 @@ Centered slide titles without the line:
|
|
|
364
433
|
```json
|
|
365
434
|
{
|
|
366
435
|
"styles": {
|
|
367
|
-
"
|
|
436
|
+
"Master-title": { "paragraph": { "fo:text-align": "center" } },
|
|
368
437
|
"Decor-ligne": { "graphic": { "draw:stroke": "none" } }
|
|
369
438
|
}
|
|
370
439
|
}
|
|
@@ -384,4 +453,4 @@ npm run build # transpile src/*.ts into dist/
|
|
|
384
453
|
npm run pub # build and publish to npmjs
|
|
385
454
|
```
|
|
386
455
|
|
|
387
|
-
Requires Node.js 20.15 or later.
|
|
456
|
+
Requires Node.js 20.15 or later. Images are converted with [sharp](https://sharp.pixelplumbing.com/), installed by npm with prebuilt binaries.
|