@tolokoban/impress 0.3.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 +69 -22
- package/dist/impress.js +850 -400
- package/dist/styles.js +28 -70
- 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,8 +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. |
|
|
30
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. |
|
|
31
57
|
|
|
32
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`.
|
|
33
59
|
|
|
@@ -138,7 +164,7 @@ Text boxes shrink their text when it does not fit (`style:shrink-to-fit`), so a
|
|
|
138
164
|
Geometry, in centimeters.
|
|
139
165
|
|
|
140
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`.
|
|
141
|
-
- `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).
|
|
142
168
|
|
|
143
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).
|
|
144
170
|
|
|
@@ -146,8 +172,17 @@ The title, the breadcrumb and the decorations of the master pages have fixed pos
|
|
|
146
172
|
|
|
147
173
|
Options for `@graph` diagrams.
|
|
148
174
|
|
|
149
|
-
- `
|
|
150
|
-
- `
|
|
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.
|
|
151
186
|
|
|
152
187
|
#### `theme.backgrounds`
|
|
153
188
|
|
|
@@ -170,7 +205,7 @@ LibreOffice ignores image adjustments inherited from a named style, so they are
|
|
|
170
205
|
|
|
171
206
|
### Placeholders
|
|
172
207
|
|
|
173
|
-
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):
|
|
174
209
|
|
|
175
210
|
```json
|
|
176
211
|
"fo:color": "{colors.primary}"
|
|
@@ -204,6 +239,7 @@ Each entry of `styles` is one named style:
|
|
|
204
239
|
| `paragraph` | Properties of the paragraphs: alignment, margins, line height… |
|
|
205
240
|
| `text` | Properties of the characters: font, size, weight, style, color… |
|
|
206
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). |
|
|
207
243
|
|
|
208
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`.
|
|
209
245
|
|
|
@@ -231,8 +267,8 @@ Since styles inherit from each other, changing a parent changes all its children
|
|
|
231
267
|
|
|
232
268
|
| Style | Element |
|
|
233
269
|
| --- | --- |
|
|
234
|
-
| `Section-title` | Title. |
|
|
235
|
-
| `Section-subtitle` | Breadcrumb under the title. |
|
|
270
|
+
| `Section-title` | Title: always the `#` heading. |
|
|
271
|
+
| `Section-subtitle` | Breadcrumb of the deeper headings, under the title. |
|
|
236
272
|
| `Section-fond` | Full-slide background rectangle. |
|
|
237
273
|
| `Section-image` | Background image (`theme.backgrounds.Section`), above `Section-fond`. |
|
|
238
274
|
| `Decor` | Horizontal bar under the title. |
|
|
@@ -255,19 +291,6 @@ Cell borders are a `paragraph` property (`fo:border`) and padding a `graphic` pr
|
|
|
255
291
|
|
|
256
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`.
|
|
257
293
|
|
|
258
|
-
**`@graph` diagrams:**
|
|
259
|
-
|
|
260
|
-
| Style | Element |
|
|
261
|
-
| --- | --- |
|
|
262
|
-
| `Graphe-noeud` | Nodes. |
|
|
263
|
-
| `Graphe-texte` | Nodes without border (`shape=plaintext`, `none`, `plain`, `underline` or `style=invis`). |
|
|
264
|
-
| `Graphe-titre` | Label of the graph (`graph [label="…"]`). |
|
|
265
|
-
| `Graphe-groupe` | Clusters (`subgraph cluster_…`). |
|
|
266
|
-
| `Graphe-lien` | Directed edges (arrow at the end). |
|
|
267
|
-
| `Graphe-lien-simple` | Edges without arrow (undirected graphs, `dir=none`). |
|
|
268
|
-
| `Graphe-lien-double` | Edges with `dir=both`. |
|
|
269
|
-
|
|
270
|
-
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.
|
|
271
294
|
|
|
272
295
|
#### Common properties
|
|
273
296
|
|
|
@@ -329,6 +352,30 @@ Styles that hold lists (`Master-outline1`, `Colonne-texte`, `Grille-texte`) have
|
|
|
329
352
|
|
|
330
353
|
Nested list items use the level of `chars` matching their depth: `Master-outline2…9` do not need a `bullets` entry of their own.
|
|
331
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.
|
|
378
|
+
|
|
332
379
|
### Table templates
|
|
333
380
|
|
|
334
381
|
`tableTemplates` tells LibreOffice which cell style each part of a table uses. There are two templates, `Tableau` and `Tableau-petit`:
|
|
@@ -406,4 +453,4 @@ npm run build # transpile src/*.ts into dist/
|
|
|
406
453
|
npm run pub # build and publish to npmjs
|
|
407
454
|
```
|
|
408
455
|
|
|
409
|
-
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.
|