decktile 0.3.7__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {decktile-0.3.7 → decktile-0.4.0}/PKG-INFO +30 -4
- {decktile-0.3.7 → decktile-0.4.0}/README.md +29 -3
- {decktile-0.3.7 → decktile-0.4.0}/pyproject.toml +3 -3
- decktile-0.4.0/src/decktile/__main__.py +7 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/cli.py +105 -8
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/parser/ast.py +2 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/parser/markdown.py +7 -1
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/plugins/fenced.py +4 -3
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/plugins/lucide.py +2 -1
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/html.py +2 -1
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/ir.py +11 -1
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/pdg.py +9 -4
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/templates/base.css +37 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/templates/decktile.js +1 -1
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/templates/shell.html +3 -3
- decktile-0.4.0/src/decktile/themes/skeleton/preview.deck.md +112 -0
- decktile-0.4.0/src/decktile/themes/skeleton/theme.toml +46 -0
- decktile-0.4.0/tests/test_cli.py +159 -0
- decktile-0.3.7/src/decktile/__main__.py +0 -7
- decktile-0.3.7/tests/test_cli.py +0 -73
- {decktile-0.3.7 → decktile-0.4.0}/LICENSE +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/NOTICE +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/__init__.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/assets/lucide/VENDORED.md +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/assets/lucide/lucide.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/assets/lucide/lucide.ttf +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/chart_themes/kubecon_na.toml +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/chart_themes/ossummit_europe.toml +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/parser/__init__.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/plugins/cards.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/plugins/directives.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/plugins/layouts.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/plugins/lucide_font.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/__init__.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/odf/__init__.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/odf/geometry.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/odf/shapes.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/odf/styles.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/odp.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/pdf.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/render/seaborn.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/theme/__init__.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/theme/loader.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/theme/parser.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/default.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/kcd_vietnam.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/kubecon_china.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/kubecon_japan.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/kubecon_na.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/ossummit_europe.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/src/decktile/themes/ossummit_korea.css +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/__init__.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_geometry.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_html.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_ir.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_odf_shapes.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_odp.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_parser.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_pdg.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_seaborn_styles.py +0 -0
- {decktile-0.3.7 → decktile-0.4.0}/tests/test_video.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: decktile
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Markdown to designed slides: HTML, PDF and editable ODP
|
|
5
5
|
Author-Email: Reza Jelveh <git@jelveh.me>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -60,7 +60,8 @@ good out of the box with minimal markup, this is the one.
|
|
|
60
60
|
```yaml
|
|
61
61
|
---
|
|
62
62
|
title: My Talk
|
|
63
|
-
theme: dynamia # theme name (default, dynamia, kubecon_japan)
|
|
63
|
+
theme: dynamia # built-in theme name (default, dynamia, kubecon_japan), or a theme folder path
|
|
64
|
+
pdg_theme: themes/brand.toml # palette for ```pdg diagrams: predictygraph theme name or .toml path
|
|
64
65
|
variant: dark # global dark mode
|
|
65
66
|
logo: assets/logo.svg # top-right logo (replaces theme default)
|
|
66
67
|
logo_dark: assets/logo-white.png # dark mode variant of logo
|
|
@@ -170,6 +171,8 @@ places that should be one. PRs that consolidate repeated logic are welcome.
|
|
|
170
171
|
@tiny text # small annotation below content
|
|
171
172
|
@variant dark # switch to dark mode for this slide
|
|
172
173
|
@hidden # exclude slide from output (alias: @hide)
|
|
174
|
+
@class a b # extra CSS classes on the slide's <section>; with two-col /
|
|
175
|
+
# image-left / image-right, cols-1-2 (also 2-1, 1-3, 3-1, 2-3, 3-2) sets the column ratio
|
|
173
176
|
{icon:star} # inline lucide icon, e.g. {icon:heart stroke=#d05a39}
|
|
174
177
|
```
|
|
175
178
|
|
|
@@ -354,6 +357,11 @@ The arrow block accepts text or images:
|
|
|
354
357
|
::: card{ tag="green" } # colored left border + background
|
|
355
358
|
::: card{ tag="quote" } # accent left border, italic, no fill
|
|
356
359
|
::: card {metric} # big number + label card (first line = value, rest = label)
|
|
360
|
+
::: card {metric kpi} # value with a bold label above it (line 2) and footnote lines below
|
|
361
|
+
::: card {tile} # no panel: big icon heading (### {icon:cpu} Title) over a caption
|
|
362
|
+
::: card {plain} # no panel, thin rule between neighbouring cards
|
|
363
|
+
::: card {person} # round photo (first image), ### name, role lines
|
|
364
|
+
::: card {logo} # one logo image centred in its cell
|
|
357
365
|
::: card {blueprint} # blue engineering-drawing panel; a ```dot inside uses the blueprint palette
|
|
358
366
|
::: arrow # connector for compare layout
|
|
359
367
|
::: notes{ tag="green" } # full-width conclusion card
|
|
@@ -368,7 +376,8 @@ The arrow block accepts text or images:
|
|
|
368
376
|
|
|
369
377
|
Card/grid `{...}` attributes: bare words are CSS classes (`{metric}` → `.card.metric`),
|
|
370
378
|
`k=v` pairs produce `k-v` classes (`{tag=green}` → `.card.tag-green`). Grid
|
|
371
|
-
also accepts `cols=N` and `class=name` literally.
|
|
379
|
+
also accepts `cols=N` and `class=name` literally. Inside a card, `### Title` is the
|
|
380
|
+
card heading and `#### Label` a section label that stays where it is written.
|
|
372
381
|
|
|
373
382
|
## Lucide icons
|
|
374
383
|
|
|
@@ -504,6 +513,23 @@ palette = ["green", "blue", "yellow"]
|
|
|
504
513
|
seaborn_theme: themes/brand.toml
|
|
505
514
|
```
|
|
506
515
|
|
|
516
|
+
### Theme folders
|
|
517
|
+
|
|
518
|
+
Keep a brand theme in your own repo as a folder next to the decks:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
decktile theme create themes/brand # theme.css, theme.toml, assets/, preview.deck.md
|
|
522
|
+
decktile -w themes/brand/preview.deck.md
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
`theme.css` replaces the built-in theme (it starts as a copy of the default),
|
|
526
|
+
`theme.toml` styles ```` ```pdg ```` diagrams and ```` ```seaborn ```` charts unless the
|
|
527
|
+
deck sets `pdg_theme`/`seaborn_theme`, and `url("assets/...")` in `theme.css`
|
|
528
|
+
resolves inside the folder. Select it per deck with `theme: themes/brand` (relative
|
|
529
|
+
to the deck) or per build with `decktile --theme themes/brand deck.md`. The folder
|
|
530
|
+
must sit inside the deck's folder, so dist/ reaches its assets. `--css file.css`
|
|
531
|
+
still layers extra CSS on top of whichever theme is active.
|
|
532
|
+
|
|
507
533
|
### Custom charts with matplotlib
|
|
508
534
|
|
|
509
535
|
For charts beyond seaborn's high-level API, drop into matplotlib directly.
|
|
@@ -563,7 +589,7 @@ transition: fade
|
|
|
563
589
|
| `zoom` | Scale .85 + fade |
|
|
564
590
|
| `wipe` | Clip-path reveal |
|
|
565
591
|
|
|
566
|
-
Clicks and taps change slides after 0.
|
|
592
|
+
Clicks and taps change slides after 0.15s, so a pinch zoom (second finger) cancels them; while zoomed in, taps do not navigate.
|
|
567
593
|
|
|
568
594
|
All transitions run 0.4s, forwards-only (incoming slide animates).
|
|
569
595
|
|
|
@@ -28,7 +28,8 @@ good out of the box with minimal markup, this is the one.
|
|
|
28
28
|
```yaml
|
|
29
29
|
---
|
|
30
30
|
title: My Talk
|
|
31
|
-
theme: dynamia # theme name (default, dynamia, kubecon_japan)
|
|
31
|
+
theme: dynamia # built-in theme name (default, dynamia, kubecon_japan), or a theme folder path
|
|
32
|
+
pdg_theme: themes/brand.toml # palette for ```pdg diagrams: predictygraph theme name or .toml path
|
|
32
33
|
variant: dark # global dark mode
|
|
33
34
|
logo: assets/logo.svg # top-right logo (replaces theme default)
|
|
34
35
|
logo_dark: assets/logo-white.png # dark mode variant of logo
|
|
@@ -138,6 +139,8 @@ places that should be one. PRs that consolidate repeated logic are welcome.
|
|
|
138
139
|
@tiny text # small annotation below content
|
|
139
140
|
@variant dark # switch to dark mode for this slide
|
|
140
141
|
@hidden # exclude slide from output (alias: @hide)
|
|
142
|
+
@class a b # extra CSS classes on the slide's <section>; with two-col /
|
|
143
|
+
# image-left / image-right, cols-1-2 (also 2-1, 1-3, 3-1, 2-3, 3-2) sets the column ratio
|
|
141
144
|
{icon:star} # inline lucide icon, e.g. {icon:heart stroke=#d05a39}
|
|
142
145
|
```
|
|
143
146
|
|
|
@@ -322,6 +325,11 @@ The arrow block accepts text or images:
|
|
|
322
325
|
::: card{ tag="green" } # colored left border + background
|
|
323
326
|
::: card{ tag="quote" } # accent left border, italic, no fill
|
|
324
327
|
::: card {metric} # big number + label card (first line = value, rest = label)
|
|
328
|
+
::: card {metric kpi} # value with a bold label above it (line 2) and footnote lines below
|
|
329
|
+
::: card {tile} # no panel: big icon heading (### {icon:cpu} Title) over a caption
|
|
330
|
+
::: card {plain} # no panel, thin rule between neighbouring cards
|
|
331
|
+
::: card {person} # round photo (first image), ### name, role lines
|
|
332
|
+
::: card {logo} # one logo image centred in its cell
|
|
325
333
|
::: card {blueprint} # blue engineering-drawing panel; a ```dot inside uses the blueprint palette
|
|
326
334
|
::: arrow # connector for compare layout
|
|
327
335
|
::: notes{ tag="green" } # full-width conclusion card
|
|
@@ -336,7 +344,8 @@ The arrow block accepts text or images:
|
|
|
336
344
|
|
|
337
345
|
Card/grid `{...}` attributes: bare words are CSS classes (`{metric}` → `.card.metric`),
|
|
338
346
|
`k=v` pairs produce `k-v` classes (`{tag=green}` → `.card.tag-green`). Grid
|
|
339
|
-
also accepts `cols=N` and `class=name` literally.
|
|
347
|
+
also accepts `cols=N` and `class=name` literally. Inside a card, `### Title` is the
|
|
348
|
+
card heading and `#### Label` a section label that stays where it is written.
|
|
340
349
|
|
|
341
350
|
## Lucide icons
|
|
342
351
|
|
|
@@ -472,6 +481,23 @@ palette = ["green", "blue", "yellow"]
|
|
|
472
481
|
seaborn_theme: themes/brand.toml
|
|
473
482
|
```
|
|
474
483
|
|
|
484
|
+
### Theme folders
|
|
485
|
+
|
|
486
|
+
Keep a brand theme in your own repo as a folder next to the decks:
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
decktile theme create themes/brand # theme.css, theme.toml, assets/, preview.deck.md
|
|
490
|
+
decktile -w themes/brand/preview.deck.md
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
`theme.css` replaces the built-in theme (it starts as a copy of the default),
|
|
494
|
+
`theme.toml` styles ```` ```pdg ```` diagrams and ```` ```seaborn ```` charts unless the
|
|
495
|
+
deck sets `pdg_theme`/`seaborn_theme`, and `url("assets/...")` in `theme.css`
|
|
496
|
+
resolves inside the folder. Select it per deck with `theme: themes/brand` (relative
|
|
497
|
+
to the deck) or per build with `decktile --theme themes/brand deck.md`. The folder
|
|
498
|
+
must sit inside the deck's folder, so dist/ reaches its assets. `--css file.css`
|
|
499
|
+
still layers extra CSS on top of whichever theme is active.
|
|
500
|
+
|
|
475
501
|
### Custom charts with matplotlib
|
|
476
502
|
|
|
477
503
|
For charts beyond seaborn's high-level API, drop into matplotlib directly.
|
|
@@ -531,7 +557,7 @@ transition: fade
|
|
|
531
557
|
| `zoom` | Scale .85 + fade |
|
|
532
558
|
| `wipe` | Clip-path reveal |
|
|
533
559
|
|
|
534
|
-
Clicks and taps change slides after 0.
|
|
560
|
+
Clicks and taps change slides after 0.15s, so a pinch zoom (second finger) cancels them; while zoomed in, taps do not navigate.
|
|
535
561
|
|
|
536
562
|
All transitions run 0.4s, forwards-only (incoming slide animates).
|
|
537
563
|
|
|
@@ -23,14 +23,14 @@ dependencies = [
|
|
|
23
23
|
]
|
|
24
24
|
requires-python = ">=3.11"
|
|
25
25
|
readme = "README.md"
|
|
26
|
-
version = "0.
|
|
26
|
+
version = "0.4.0"
|
|
27
27
|
|
|
28
28
|
[project.license]
|
|
29
29
|
text = "Apache-2.0"
|
|
30
30
|
|
|
31
31
|
[project.scripts]
|
|
32
|
-
decktile = "decktile.cli:
|
|
33
|
-
slidr = "decktile.cli:
|
|
32
|
+
decktile = "decktile.cli:run"
|
|
33
|
+
slidr = "decktile.cli:run"
|
|
34
34
|
|
|
35
35
|
[project.urls]
|
|
36
36
|
Homepage = "https://github.com/decktile/decktile"
|
|
@@ -6,19 +6,57 @@
|
|
|
6
6
|
|
|
7
7
|
import glob
|
|
8
8
|
import re
|
|
9
|
+
import sys
|
|
9
10
|
import time
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
|
|
12
13
|
import typer
|
|
13
14
|
|
|
14
15
|
from decktile.parser.markdown import parse
|
|
15
|
-
from decktile.render.html import base_css, default_theme, load_theme
|
|
16
|
+
from decktile.render.html import THEME_DIR, base_css, default_theme, load_theme
|
|
16
17
|
from decktile.render.html import render as render_html
|
|
17
18
|
from decktile.render.ir import assemble_css
|
|
18
19
|
from decktile.render.odp import render as render_odp
|
|
19
20
|
from decktile.render.pdf import render as render_pdf
|
|
20
21
|
|
|
21
22
|
app = typer.Typer(help="Markdown to styled HTML + ODP + PDF", no_args_is_help=True)
|
|
23
|
+
theme_app = typer.Typer(help="Manage theme folders", no_args_is_help=True)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def run() -> None:
|
|
27
|
+
"""Console entry point. `decktile theme ...` goes to the theme commands; the
|
|
28
|
+
main command takes any number of deck files, so it can't host subcommands."""
|
|
29
|
+
if sys.argv[1:2] == ["theme"]:
|
|
30
|
+
theme_app(args=sys.argv[2:], prog_name="decktile theme")
|
|
31
|
+
else:
|
|
32
|
+
app()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@theme_app.callback()
|
|
36
|
+
def _theme_group() -> None:
|
|
37
|
+
"""Manage theme folders."""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@theme_app.command("create")
|
|
41
|
+
def theme_create(path: Path = typer.Argument(..., help="Folder to create, e.g. themes/acme")) -> None:
|
|
42
|
+
"""Create a theme folder: theme.css (a copy of the default theme), theme.toml
|
|
43
|
+
(diagram and chart palette), assets/, and preview.deck.md to try it on."""
|
|
44
|
+
if path.exists() and (not path.is_dir() or any(path.iterdir())):
|
|
45
|
+
_error(path, "already exists and is not an empty folder")
|
|
46
|
+
raise typer.Exit(1)
|
|
47
|
+
name = path.resolve().name
|
|
48
|
+
skeleton = THEME_DIR / "skeleton"
|
|
49
|
+
(path / "assets").mkdir(parents=True, exist_ok=True)
|
|
50
|
+
header = (
|
|
51
|
+
f"/* {name}: decktile theme folder. Starts as a copy of decktile's default theme.\n"
|
|
52
|
+
" Use it with `theme: <path to this folder>` in a deck's frontmatter, or\n"
|
|
53
|
+
' `decktile --theme <folder>`. url("assets/...") resolves inside this folder. */\n\n'
|
|
54
|
+
)
|
|
55
|
+
(path / "theme.css").write_text(header + default_theme(), encoding="utf-8")
|
|
56
|
+
for f in ("theme.toml", "preview.deck.md"):
|
|
57
|
+
(path / f).write_text((skeleton / f).read_text(encoding="utf-8").replace("THEME_NAME", name), encoding="utf-8")
|
|
58
|
+
typer.echo(f"Created {path}/: theme.css, theme.toml, assets/, preview.deck.md")
|
|
59
|
+
typer.echo(f"Preview: decktile -w {path / 'preview.deck.md'}")
|
|
22
60
|
|
|
23
61
|
|
|
24
62
|
@app.callback(invoke_without_command=True)
|
|
@@ -38,26 +76,32 @@ def main(
|
|
|
38
76
|
),
|
|
39
77
|
watch: bool = typer.Option(False, "-w", "--watch", help="Watch file and rebuild on changes"),
|
|
40
78
|
debug: bool = typer.Option(False, "--debug", help="Dump AST + write debug CSS"),
|
|
41
|
-
css: Path | None = typer.Option(None, "--css", help="
|
|
79
|
+
css: Path | None = typer.Option(None, "--css", help="Extra CSS file layered on top of the deck's theme"),
|
|
80
|
+
theme: Path | None = typer.Option(
|
|
81
|
+
None, "--theme", help="Theme folder (theme.css, optional theme.toml); overrides the deck's theme"
|
|
82
|
+
),
|
|
42
83
|
):
|
|
43
84
|
if not files:
|
|
44
85
|
raise typer.Exit()
|
|
45
86
|
if css and not css.is_file():
|
|
46
87
|
_error(css, "CSS file not found")
|
|
47
88
|
raise typer.Exit(1)
|
|
89
|
+
if theme and not (theme / "theme.css").is_file():
|
|
90
|
+
_error(theme, "not a theme folder (no theme.css)")
|
|
91
|
+
raise typer.Exit(1)
|
|
48
92
|
|
|
49
93
|
paths, missing = _expand(files)
|
|
50
94
|
for f in missing:
|
|
51
95
|
_error(f, "no files match" if any(c in str(f) for c in "*?[") else "not a file" if f.exists() else "no such file")
|
|
52
96
|
|
|
53
97
|
if watch:
|
|
54
|
-
_watch(paths, output_dir, pdf, odp, image_odp, debug, css)
|
|
98
|
+
_watch(paths, output_dir, pdf, odp, image_odp, debug, css, theme)
|
|
55
99
|
return
|
|
56
100
|
|
|
57
101
|
failed = len(missing)
|
|
58
102
|
for f in paths:
|
|
59
103
|
try:
|
|
60
|
-
_build(f, output_dir, pdf, odp, image_odp, dist, optimize_images, debug, css)
|
|
104
|
+
_build(f, output_dir, pdf, odp, image_odp, dist, optimize_images, debug, css, theme)
|
|
61
105
|
except Exception as e:
|
|
62
106
|
if debug:
|
|
63
107
|
raise
|
|
@@ -102,11 +146,29 @@ def _build(
|
|
|
102
146
|
optimize_images: bool,
|
|
103
147
|
debug: bool,
|
|
104
148
|
css_path: Path | None,
|
|
149
|
+
theme_dir: Path | None = None,
|
|
105
150
|
) -> None:
|
|
106
151
|
content = file.read_text(encoding="utf-8")
|
|
107
152
|
doc = parse(content)
|
|
108
|
-
|
|
153
|
+
# a theme folder: --theme, else a frontmatter `theme:` that is a path (built-in
|
|
154
|
+
# names never contain "/"), so a mistyped folder errors instead of silently
|
|
155
|
+
# building with the default theme
|
|
156
|
+
meta_theme = doc.meta.theme or ""
|
|
157
|
+
if theme_dir is None and meta_theme and ("/" in meta_theme or meta_theme.startswith(".") or (file.parent / meta_theme).is_dir()):
|
|
158
|
+
theme_dir = file.parent / meta_theme
|
|
159
|
+
theme_css = None
|
|
160
|
+
if theme_dir is not None:
|
|
161
|
+
theme_css = _folder_theme_css(theme_dir, file.parent)
|
|
162
|
+
# theme.toml carries the pdg and seaborn palettes unless the deck names its own
|
|
163
|
+
if (theme_dir / "theme.toml").is_file():
|
|
164
|
+
toml = str((theme_dir / "theme.toml").resolve())
|
|
165
|
+
doc.meta.pdg_theme = doc.meta.pdg_theme or toml
|
|
166
|
+
doc.meta.seaborn_theme = doc.meta.seaborn_theme or toml
|
|
167
|
+
# downstream theme files, relative to the deck
|
|
168
|
+
if doc.meta.seaborn_theme.endswith(".toml"):
|
|
109
169
|
doc.meta.seaborn_theme = str((file.parent / doc.meta.seaborn_theme).resolve())
|
|
170
|
+
if doc.meta.pdg_theme.endswith(".toml"):
|
|
171
|
+
doc.meta.pdg_theme = str((file.parent / doc.meta.pdg_theme).resolve())
|
|
110
172
|
dims = doc.meta.dimensions()
|
|
111
173
|
|
|
112
174
|
out_dir = output_dir or file.parent / "dist"
|
|
@@ -114,7 +176,8 @@ def _build(
|
|
|
114
176
|
_symlink_assets(file.parent, out_dir)
|
|
115
177
|
stem = file.name.removesuffix(".deck.md") if file.name.endswith(".deck.md") else file.stem
|
|
116
178
|
|
|
117
|
-
|
|
179
|
+
if theme_css is None:
|
|
180
|
+
theme_css = load_theme(doc.meta.theme) if doc.meta.theme not in (None, "", "default") else default_theme()
|
|
118
181
|
if css_path and css_path.is_file():
|
|
119
182
|
theme_css += "\n" + css_path.read_text(encoding="utf-8")
|
|
120
183
|
theme_css += "\n" + (doc.meta.style or "")
|
|
@@ -174,7 +237,16 @@ def _build(
|
|
|
174
237
|
typer.echo(f" {type(n).__name__}: {_node_summary(n)}")
|
|
175
238
|
|
|
176
239
|
|
|
177
|
-
def _watch(
|
|
240
|
+
def _watch(
|
|
241
|
+
files: list[Path],
|
|
242
|
+
output_dir: Path | None,
|
|
243
|
+
pdf: bool,
|
|
244
|
+
odp: bool,
|
|
245
|
+
image_odp: bool,
|
|
246
|
+
debug: bool,
|
|
247
|
+
css_path: Path | None,
|
|
248
|
+
theme_dir: Path | None,
|
|
249
|
+
) -> None:
|
|
178
250
|
if not files:
|
|
179
251
|
raise typer.Exit(1)
|
|
180
252
|
mtimes: dict[Path, float] = {}
|
|
@@ -191,7 +263,7 @@ def _watch(files: list[Path], output_dir: Path | None, pdf: bool, odp: bool, ima
|
|
|
191
263
|
mtimes[f] = mtime
|
|
192
264
|
typer.echo("---")
|
|
193
265
|
try:
|
|
194
|
-
_build(f, output_dir, pdf, odp, image_odp, False, False, debug, css_path)
|
|
266
|
+
_build(f, output_dir, pdf, odp, image_odp, False, False, debug, css_path, theme_dir)
|
|
195
267
|
except Exception as e:
|
|
196
268
|
_error(f, e)
|
|
197
269
|
time.sleep(1)
|
|
@@ -251,6 +323,31 @@ def _symlink_assets(source_dir: Path, dist_dir: Path) -> None:
|
|
|
251
323
|
dest.symlink_to(item.resolve())
|
|
252
324
|
|
|
253
325
|
|
|
326
|
+
_CSS_URL = re.compile(r"""url\(\s*(['"]?)([^'")]+)\1\s*\)""")
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def _folder_theme_css(theme_dir: Path, deck_dir: Path) -> str:
|
|
330
|
+
"""Read a theme folder's theme.css with its relative url()s rebased onto the
|
|
331
|
+
deck folder, the base every output (HTML in dist/ via the asset symlinks,
|
|
332
|
+
PDF, ODP, --dist zip) resolves paths from. So the folder must sit inside the
|
|
333
|
+
deck folder: from anywhere else its assets are unreachable from dist/."""
|
|
334
|
+
css_file = theme_dir / "theme.css"
|
|
335
|
+
if not css_file.is_file():
|
|
336
|
+
raise FileNotFoundError(f"theme folder has no theme.css: {theme_dir}")
|
|
337
|
+
root, deck = theme_dir.resolve(), deck_dir.resolve()
|
|
338
|
+
if not root.is_relative_to(deck):
|
|
339
|
+
raise ValueError(f"theme folder {theme_dir} must be inside the deck folder {deck_dir}")
|
|
340
|
+
prefix = root.relative_to(deck).as_posix()
|
|
341
|
+
|
|
342
|
+
def rebase(m: re.Match) -> str:
|
|
343
|
+
q, url = m.groups()
|
|
344
|
+
if url.startswith(("data:", "http:", "https:", "#", "/", "var(")):
|
|
345
|
+
return m.group(0)
|
|
346
|
+
return f"url({q}{prefix}/{url}{q})"
|
|
347
|
+
|
|
348
|
+
return _CSS_URL.sub(rebase, css_file.read_text(encoding="utf-8"))
|
|
349
|
+
|
|
350
|
+
|
|
254
351
|
def _make_dist(source_dir: Path, out_dir: Path, html_path: Path, html: str, theme_css: str, stem: str) -> None:
|
|
255
352
|
import zipfile
|
|
256
353
|
|
|
@@ -32,6 +32,7 @@ class Meta:
|
|
|
32
32
|
background: str = ""
|
|
33
33
|
pygments_style: str = "default"
|
|
34
34
|
seaborn_theme: str = ""
|
|
35
|
+
pdg_theme: str = ""
|
|
35
36
|
theme_variant: str = "light"
|
|
36
37
|
transition: str = ""
|
|
37
38
|
autoplay: int = 7
|
|
@@ -62,6 +63,7 @@ class Slide:
|
|
|
62
63
|
notes: str = ""
|
|
63
64
|
variant: str = ""
|
|
64
65
|
transition: str = ""
|
|
66
|
+
classes: str = ""
|
|
65
67
|
|
|
66
68
|
|
|
67
69
|
class Node:
|
|
@@ -65,6 +65,7 @@ def parse(input_text: str) -> Document:
|
|
|
65
65
|
background=background_raw,
|
|
66
66
|
pygments_style=raw_meta.pop("pygments_style", "default"),
|
|
67
67
|
seaborn_theme=raw_meta.pop("seaborn_theme", None) or Meta.seaborn_theme,
|
|
68
|
+
pdg_theme=raw_meta.pop("pdg_theme", None) or Meta.pdg_theme,
|
|
68
69
|
theme_variant=raw_meta.pop("variant", Meta.theme_variant),
|
|
69
70
|
transition=raw_meta.pop("transition", Meta.transition),
|
|
70
71
|
autoplay=raw_meta.pop("autoplay", Meta.autoplay),
|
|
@@ -122,6 +123,7 @@ def _parse_slide(content: str) -> Slide:
|
|
|
122
123
|
layout = _detect_layout(nodes)
|
|
123
124
|
variant = ""
|
|
124
125
|
transition = ""
|
|
126
|
+
classes = []
|
|
125
127
|
hidden = False
|
|
126
128
|
for n in list(nodes):
|
|
127
129
|
if isinstance(n, AttrNode) and n.type == "layout":
|
|
@@ -133,6 +135,10 @@ def _parse_slide(content: str) -> Slide:
|
|
|
133
135
|
elif isinstance(n, AttrNode) and n.type == "transition":
|
|
134
136
|
transition = n.value.strip()
|
|
135
137
|
nodes.remove(n)
|
|
138
|
+
elif isinstance(n, AttrNode) and n.type == "class":
|
|
139
|
+
# class names land in an HTML attribute: keep only CSS identifiers
|
|
140
|
+
classes += [c for c in n.value.split() if re.fullmatch(r"[A-Za-z_][\w-]*", c)]
|
|
141
|
+
nodes.remove(n)
|
|
136
142
|
elif isinstance(n, AttrNode) and n.type in ("hidden", "hide"):
|
|
137
143
|
hidden = True
|
|
138
144
|
nodes.remove(n)
|
|
@@ -140,7 +146,7 @@ def _parse_slide(content: str) -> Slide:
|
|
|
140
146
|
if hidden:
|
|
141
147
|
return None
|
|
142
148
|
|
|
143
|
-
return Slide(layout=layout, children=nodes, notes=notes, variant=variant, transition=transition)
|
|
149
|
+
return Slide(layout=layout, children=nodes, notes=notes, variant=variant, transition=transition, classes=" ".join(classes))
|
|
144
150
|
|
|
145
151
|
|
|
146
152
|
def _tokens_to_nodes(tokens: list[Token]) -> list:
|
|
@@ -13,13 +13,11 @@ import re
|
|
|
13
13
|
from markdown_it import MarkdownIt
|
|
14
14
|
|
|
15
15
|
from decktile.parser.ast import Arrow, Card, CodeBlock, Grid, Node, Notes
|
|
16
|
-
from decktile.plugins.lucide import lucide_plugin
|
|
16
|
+
from decktile.plugins.lucide import _ICON_RE, lucide_plugin
|
|
17
17
|
|
|
18
18
|
_CARD_MD = MarkdownIt("gfm-like", {"breaks": False, "html": True, "linkify": True})
|
|
19
19
|
_CARD_MD.use(lucide_plugin)
|
|
20
20
|
|
|
21
|
-
_ICON_RE = re.compile(r"\{icon:(\S+)\s*([^}]*)\}")
|
|
22
|
-
|
|
23
21
|
|
|
24
22
|
def _expand_icons(text: str) -> str:
|
|
25
23
|
"""Expand {icon:...} markers using the shared lucide plugin renderer."""
|
|
@@ -121,6 +119,9 @@ def _parse_card(text: str, rest: str = "") -> Card:
|
|
|
121
119
|
continue
|
|
122
120
|
elif line.startswith("### "):
|
|
123
121
|
header = _expand_markdown(line[4:])
|
|
122
|
+
elif line.startswith("#### "):
|
|
123
|
+
# section label inside the card, kept in place among the body lines
|
|
124
|
+
body.append(f"<h4>{_expand_markdown(line[5:])}</h4>")
|
|
124
125
|
elif line.startswith("- "):
|
|
125
126
|
items = []
|
|
126
127
|
while i < len(lines) and lines[i].strip().startswith("- "):
|
|
@@ -8,7 +8,8 @@ import re
|
|
|
8
8
|
|
|
9
9
|
from markdown_it.rules_inline import StateInline
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# name stops at "}" so "{icon:mail} a {icon:x}" is two icons, not one named "mail}"
|
|
12
|
+
_ICON_RE = re.compile(r"\{icon:([^\s}]+)\s*([^}]*)\}")
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def render_icon(name: str, attrs: dict[str, str] | None = None) -> str:
|
|
@@ -84,6 +84,7 @@ def render_from_ir(ir_slides: list[SlideIR], doc: Document, assembled_css: str,
|
|
|
84
84
|
"paginate": doc.meta.paginate or False,
|
|
85
85
|
"variant": slide.variant or doc.meta.theme_variant,
|
|
86
86
|
"transition": slide.transition or doc.meta.transition or "",
|
|
87
|
+
"classes": slide.classes,
|
|
87
88
|
}
|
|
88
89
|
)
|
|
89
90
|
|
|
@@ -189,7 +190,7 @@ def _render_elem(e: Elem) -> str:
|
|
|
189
190
|
if e.header:
|
|
190
191
|
s += f"<h3>{e.header}</h3>\n"
|
|
191
192
|
for line in e.body:
|
|
192
|
-
if line.startswith("<ul"
|
|
193
|
+
if line.startswith(("<ul", "<ol", "<h4")):
|
|
193
194
|
s += line + "\n"
|
|
194
195
|
else:
|
|
195
196
|
s += f"<p>{line}</p>\n"
|
|
@@ -148,11 +148,14 @@ class SlideIR:
|
|
|
148
148
|
notes: str = ""
|
|
149
149
|
variant: str = ""
|
|
150
150
|
transition: str = ""
|
|
151
|
+
classes: str = "" # extra section classes from @class
|
|
151
152
|
|
|
152
153
|
|
|
153
154
|
def build_ir(doc: Document, base_css: str = "", theme_css: str = "") -> list[SlideIR]:
|
|
154
155
|
"""Convert a Document AST into a list of SlideIR objects."""
|
|
155
156
|
styles = resolve_styles(base_css, theme_css) if base_css else {}
|
|
157
|
+
if doc.meta.pdg_theme:
|
|
158
|
+
styles["pdg_theme"] = doc.meta.pdg_theme
|
|
156
159
|
slides = []
|
|
157
160
|
for idx, slide in enumerate(doc.slides):
|
|
158
161
|
layout = slide.layout
|
|
@@ -187,6 +190,7 @@ def build_ir(doc: Document, base_css: str = "", theme_css: str = "") -> list[Sli
|
|
|
187
190
|
notes=slide.notes or "",
|
|
188
191
|
variant=slide.variant or "",
|
|
189
192
|
transition=slide.transition or "",
|
|
193
|
+
classes=slide.classes,
|
|
190
194
|
)
|
|
191
195
|
)
|
|
192
196
|
_assign_elem_ids(slides)
|
|
@@ -440,7 +444,13 @@ def _convert_node(node, styles: dict) -> Elem:
|
|
|
440
444
|
fam = styles.get("font_body_family", "")
|
|
441
445
|
size = styles.get("font_body", 18)
|
|
442
446
|
tags = styles.get("tag_colors", {})
|
|
443
|
-
opts = dict(
|
|
447
|
+
opts = dict(
|
|
448
|
+
font_family=fam,
|
|
449
|
+
font_size=size,
|
|
450
|
+
tag_colors=tags,
|
|
451
|
+
blueprint=styles.get("pdg_blueprint", False),
|
|
452
|
+
theme=styles.get("pdg_theme", ""),
|
|
453
|
+
)
|
|
444
454
|
svg = render_pdg_svg(node.content, **opts) or ""
|
|
445
455
|
live = render_pdg_svg(node.content, animated=True, **opts) or ""
|
|
446
456
|
# only keep the animated copy when the diagram actually moves
|
|
@@ -59,24 +59,29 @@ def render_pdg_svg(
|
|
|
59
59
|
tag_colors: dict[str, tuple[str, str]] | None = None,
|
|
60
60
|
blueprint: bool = False,
|
|
61
61
|
animated: bool = False,
|
|
62
|
+
theme: str = "",
|
|
62
63
|
) -> str | None:
|
|
63
64
|
"""Render a predictygraph diagram to SVG, or None if it fails to parse.
|
|
64
65
|
|
|
65
66
|
``blueprint`` uses the palette for ``::: card {blueprint}`` (light lines,
|
|
66
67
|
translucent fills). ``animated`` keeps predictygraph's SMIL animation
|
|
67
68
|
(``flow=``, ``border=``) for HTML; the default is a still frame, which PDF
|
|
68
|
-
and ODP need.
|
|
69
|
+
and ODP need. ``theme`` is the deck's ``pdg_theme`` (a predictygraph theme
|
|
70
|
+
name or ``.toml`` path): it replaces the slide's tag colours, the slide
|
|
71
|
+
font still applies.
|
|
69
72
|
"""
|
|
70
73
|
import predictygraph
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
own_theme = bool(_OWN_THEME.search(content))
|
|
76
|
+
deck_theme = theme if theme and not blueprint and not own_theme else None
|
|
77
|
+
css = theme_css(font_family, font_size, _BLUEPRINT_TAGS if blueprint else None if deck_theme else tag_colors)
|
|
73
78
|
if blueprint:
|
|
74
79
|
css += "\n" + _BLUEPRINT_CSS
|
|
75
80
|
# A diagram's own theme= wins over the slide theme; otherwise slide theme
|
|
76
81
|
# goes first so css inside the block overrides it.
|
|
77
|
-
text = content if
|
|
82
|
+
text = content if own_theme else "css {\n" + css + "\n}\n" + content
|
|
78
83
|
try:
|
|
79
|
-
svg = predictygraph.render(text, t=None if animated else 0)
|
|
84
|
+
svg = predictygraph.render(text, t=None if animated else 0, theme=deck_theme)
|
|
80
85
|
except Exception:
|
|
81
86
|
return None
|
|
82
87
|
return _strip_xml_decl(svg)
|
|
@@ -191,6 +191,35 @@ th { font-weight: 700; }
|
|
|
191
191
|
line-height: 1.3;
|
|
192
192
|
margin: 0;
|
|
193
193
|
}
|
|
194
|
+
/* {metric kpi}: bold label above the value, further lines a footnote below
|
|
195
|
+
("Peak Scheduling Scale / 1,800 Pods / ...") */
|
|
196
|
+
.card.metric.kpi { display: flex; flex-direction: column; text-align: left; }
|
|
197
|
+
.card.metric.kpi h3 { order: 2; font-size: 1.4em; margin: 0.05em 0 0.15em; }
|
|
198
|
+
.card.metric.kpi p { order: 3; }
|
|
199
|
+
.card.metric.kpi p:first-of-type { order: 1; font-weight: 700; color: var(--color-foreground); }
|
|
200
|
+
|
|
201
|
+
/* {tile}: large icon over title over caption, no panel. The lucide icon sets an
|
|
202
|
+
inline height:1em; the tile's icon is the visual, hence !important. */
|
|
203
|
+
.card.tile { text-align: center; background: none; border: none; }
|
|
204
|
+
.card.tile h3 svg { display: block; width: 3em !important; height: 3em !important; margin: 0 auto 0.6em; }
|
|
205
|
+
.card.tile p { color: var(--color-accent-primary); }
|
|
206
|
+
|
|
207
|
+
/* {plain}: a column without a panel, thin rule between neighbours */
|
|
208
|
+
.card.plain { background: none; border: none; border-left: 1px solid var(--color-border); border-radius: 0; padding: 0.3em 0.8em; }
|
|
209
|
+
.card.plain:first-child { border-left: none; padding-left: 0; }
|
|
210
|
+
|
|
211
|
+
/* {person}: round photo, name, role. The photo sits in a <p>: reset its font
|
|
212
|
+
size so it is sized in slide em, not caption em. */
|
|
213
|
+
.card.person { background: none; border: none; text-align: center; padding: 0.2em; }
|
|
214
|
+
.card.person p:has(img) { font-size: 1em; }
|
|
215
|
+
.card.person img { width: 4.2em; height: 4.2em; border-radius: 50%; object-fit: cover; margin: 0 auto 0.4em; }
|
|
216
|
+
.card.person h3 { margin-bottom: 0.15em; }
|
|
217
|
+
.card.person p { color: var(--color-dimmed); }
|
|
218
|
+
|
|
219
|
+
/* {logo}: one logo centred in its cell */
|
|
220
|
+
.card.logo { display: flex; align-items: center; justify-content: center; padding: 0.4em; }
|
|
221
|
+
.card.logo img { max-height: 1.8em; width: auto; }
|
|
222
|
+
|
|
194
223
|
/* metrics-N layout: center grid vertically in slide body */
|
|
195
224
|
[class*="layout-metrics"] .slide-body {
|
|
196
225
|
display: flex;
|
|
@@ -306,6 +335,14 @@ LOGO_CSS
|
|
|
306
335
|
align-items: start;
|
|
307
336
|
height: 100%;
|
|
308
337
|
}
|
|
338
|
+
/* @class cols-L-R: column width ratio for two-col / image-left / image-right
|
|
339
|
+
(left:right). Compare keeps its own card | arrow | card grid. */
|
|
340
|
+
.cols-1-2 .layout-cols:not(.compare) { grid-template-columns: 1fr 2fr; }
|
|
341
|
+
.cols-2-1 .layout-cols:not(.compare) { grid-template-columns: 2fr 1fr; }
|
|
342
|
+
.cols-1-3 .layout-cols:not(.compare) { grid-template-columns: 1fr 3fr; }
|
|
343
|
+
.cols-3-1 .layout-cols:not(.compare) { grid-template-columns: 3fr 1fr; }
|
|
344
|
+
.cols-2-3 .layout-cols:not(.compare) { grid-template-columns: 2fr 3fr; }
|
|
345
|
+
.cols-3-2 .layout-cols:not(.compare) { grid-template-columns: 3fr 2fr; }
|
|
309
346
|
|
|
310
347
|
.layout-image-right .col-right,
|
|
311
348
|
.layout-image-left .col-left {
|
|
@@ -16,7 +16,7 @@ function tapDirection(e, el) {
|
|
|
16
16
|
|
|
17
17
|
// Clicks navigate after a short delay so a pinch zoom can cancel them: a second
|
|
18
18
|
// finger, a zoom change or a zoomed-in page means the user wants to look closer.
|
|
19
|
-
var TAP_DELAY =
|
|
19
|
+
var TAP_DELAY = 150;
|
|
20
20
|
var _tapTimer = null;
|
|
21
21
|
function _zoomed() { return window.visualViewport && window.visualViewport.scale > 1.01; }
|
|
22
22
|
function _cancelTap() { clearTimeout(_tapTimer); _tapTimer = null; }
|
|
@@ -69,7 +69,7 @@ body.autoplay-looping { opacity: 0; }
|
|
|
69
69
|
</head>
|
|
70
70
|
<body>
|
|
71
71
|
{% for slide in slides %}
|
|
72
|
-
<section class="slide layout-{{ slide.layout }}" data-decktile-id="{{ slide.id }}"{% if slide.variant %} data-theme="{{ slide.variant }}"{% endif %}{% if slide.transition %} data-transition="{{ slide.transition }}"{% endif %}>
|
|
72
|
+
<section class="slide layout-{{ slide.layout }}{% if slide.classes %} {{ slide.classes }}{% endif %}" data-decktile-id="{{ slide.id }}"{% if slide.variant %} data-theme="{{ slide.variant }}"{% endif %}{% if slide.transition %} data-transition="{{ slide.transition }}"{% endif %}>
|
|
73
73
|
{{ slide.children }}
|
|
74
74
|
{% if slide.footer %}<footer>{{ slide.footer }}</footer>{% endif %}
|
|
75
75
|
{% if slide.paginate %}<span class="slide-num">{{ slide.num }}</span>{% endif %}
|
|
@@ -88,12 +88,12 @@ body.autoplay-looping { opacity: 0; }
|
|
|
88
88
|
<div id="presenter-panel">
|
|
89
89
|
<div id="pres-main">
|
|
90
90
|
{% for slide in slides %}
|
|
91
|
-
<section class="slide layout-{{ slide.layout }}"{% if slide.variant %} data-theme="{{ slide.variant }}"{% endif %}>{{ slide.children }}</section>
|
|
91
|
+
<section class="slide layout-{{ slide.layout }}{% if slide.classes %} {{ slide.classes }}{% endif %}"{% if slide.variant %} data-theme="{{ slide.variant }}"{% endif %}>{{ slide.children }}</section>
|
|
92
92
|
{% endfor %}
|
|
93
93
|
</div>
|
|
94
94
|
<div id="pres-next">
|
|
95
95
|
{% for slide in slides %}
|
|
96
|
-
<section class="slide layout-{{ slide.layout }}"{% if slide.variant %} data-theme="{{ slide.variant }}"{% endif %}>{{ slide.children }}</section>
|
|
96
|
+
<section class="slide layout-{{ slide.layout }}{% if slide.classes %} {{ slide.classes }}{% endif %}"{% if slide.variant %} data-theme="{{ slide.variant }}"{% endif %}>{{ slide.children }}</section>
|
|
97
97
|
{% endfor %}
|
|
98
98
|
</div>
|
|
99
99
|
<div id="pres-notes"><button id="pres-autoplay" title="Toggle autoplay" style="font-size:18px;background:#333;border:1px solid #555;color:#eee;padding:4px 12px;cursor:pointer;margin-bottom:8px;border-radius:4px">⏯</button> <button id="pres-speed-dec" title="Faster" style="font-size:16px;background:#333;border:1px solid #555;color:#eee;padding:4px 10px;cursor:pointer;margin-bottom:8px;border-radius:4px">−</button> <span id="pres-speed-val" style="display:inline-block;min-width:3em;text-align:center">{{ autoplay }}s</span> <button id="pres-speed-inc" title="Slower" style="font-size:16px;background:#333;border:1px solid #555;color:#eee;padding:4px 10px;cursor:pointer;margin-bottom:8px;border-radius:4px">+</button><br><span id="pres-notes-text"></span></div>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
theme: .
|
|
3
|
+
size: 16:9
|
|
4
|
+
paginate: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
@kicker THEME_NAME
|
|
8
|
+
# Theme preview
|
|
9
|
+
@subtitle Edit theme.css and theme.toml, then rebuild this deck
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Text and lists
|
|
14
|
+
|
|
15
|
+
Body text with **bold**, *italic*, `code` and a [link](https://example.com).
|
|
16
|
+
|
|
17
|
+
- First point
|
|
18
|
+
- Second point
|
|
19
|
+
|
|
20
|
+
#### Section label
|
|
21
|
+
|
|
22
|
+
> A quote
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Cards
|
|
27
|
+
|
|
28
|
+
::: card {tag=green}
|
|
29
|
+
### Green
|
|
30
|
+
Tag colour
|
|
31
|
+
:::
|
|
32
|
+
::: card {tag=cyan}
|
|
33
|
+
### Cyan
|
|
34
|
+
Tag colour
|
|
35
|
+
:::
|
|
36
|
+
::: card {tag=yellow}
|
|
37
|
+
### Yellow
|
|
38
|
+
Tag colour
|
|
39
|
+
:::
|
|
40
|
+
::: card {tag=red}
|
|
41
|
+
### Red
|
|
42
|
+
Tag colour
|
|
43
|
+
:::
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Metrics
|
|
48
|
+
|
|
49
|
+
::: card {metric}
|
|
50
|
+
42%
|
|
51
|
+
Plain metric
|
|
52
|
+
:::
|
|
53
|
+
::: card {metric kpi}
|
|
54
|
+
1,800 Pods
|
|
55
|
+
Peak scale
|
|
56
|
+
Footnote line
|
|
57
|
+
:::
|
|
58
|
+
::: card {tile}
|
|
59
|
+
### {icon:cpu} Tile
|
|
60
|
+
Icon over caption
|
|
61
|
+
:::
|
|
62
|
+
::: card {plain}
|
|
63
|
+
### Plain
|
|
64
|
+
Column without a panel
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
@layout two-col
|
|
70
|
+
@class cols-1-2
|
|
71
|
+
|
|
72
|
+
## Table and diagram
|
|
73
|
+
|
|
74
|
+
| Workload | Allocation |
|
|
75
|
+
|---|---|
|
|
76
|
+
| Inference | Shared |
|
|
77
|
+
| Training | Dedicated |
|
|
78
|
+
|
|
79
|
+
@col
|
|
80
|
+
|
|
81
|
+
```pdg
|
|
82
|
+
graph dir=LR
|
|
83
|
+
a "Request" .soft
|
|
84
|
+
b "Scheduler" .accent
|
|
85
|
+
c "GPU"
|
|
86
|
+
a -> b -> c .accent
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
@variant dark
|
|
92
|
+
|
|
93
|
+
## Dark variant
|
|
94
|
+
|
|
95
|
+
::: card {tag=cyan}
|
|
96
|
+
### Card on dark
|
|
97
|
+
Text
|
|
98
|
+
:::
|
|
99
|
+
::: card
|
|
100
|
+
### Default card
|
|
101
|
+
Text
|
|
102
|
+
:::
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Chart
|
|
107
|
+
|
|
108
|
+
```seaborn
|
|
109
|
+
import matplotlib.pyplot as plt
|
|
110
|
+
fig, ax = plt.subplots(figsize=(8, 3.5))
|
|
111
|
+
ax.bar(["A", "B", "C", "D"], [3, 5, 2, 4], color=[f"C{i}" for i in range(4)])
|
|
112
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Palette for ```pdg diagrams and ```seaborn charts in decks using this theme.
|
|
2
|
+
# Keep the colours in step with theme.css. Format: predictygraph theme
|
|
3
|
+
# (pdg --help-theme); the [seaborn] table holds matplotlib rcParams.
|
|
4
|
+
schema = 1
|
|
5
|
+
name = "THEME_NAME"
|
|
6
|
+
dark = false
|
|
7
|
+
|
|
8
|
+
# CSS for diagrams: node/group/edge classes usable as `.name` in pdg blocks
|
|
9
|
+
css = """
|
|
10
|
+
node.accent { fill: #0288d1; color: #ffffff; }
|
|
11
|
+
node.soft { fill: #e0f7fa; color: #333333; }
|
|
12
|
+
group.soft { fill: #f5f5f5; stroke: #dddddd; }
|
|
13
|
+
edge.accent { stroke: #0288d1; }
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
[palette]
|
|
17
|
+
bg = "#ffffff"
|
|
18
|
+
bg-alt = "#f5f5f5"
|
|
19
|
+
surface = "#fafafa"
|
|
20
|
+
fg = "#333333"
|
|
21
|
+
muted = "#777777"
|
|
22
|
+
border = "#dddddd"
|
|
23
|
+
red = "#ff7a7a"
|
|
24
|
+
orange = "#ffb347"
|
|
25
|
+
yellow = "#ffd166"
|
|
26
|
+
green = "#0fd05d"
|
|
27
|
+
cyan = "#67d8ff"
|
|
28
|
+
blue = "#0288d1"
|
|
29
|
+
purple = "#7e57c2"
|
|
30
|
+
|
|
31
|
+
[roles]
|
|
32
|
+
accent = "blue"
|
|
33
|
+
edge = "fg"
|
|
34
|
+
group-text = "fg"
|
|
35
|
+
|
|
36
|
+
[shape]
|
|
37
|
+
radius = 4
|
|
38
|
+
font = "Roboto"
|
|
39
|
+
|
|
40
|
+
[seaborn]
|
|
41
|
+
palette = ["blue", "green", "orange", "red", "purple", "cyan"]
|
|
42
|
+
"axes.edgecolor" = "#dddddd"
|
|
43
|
+
"axes.labelcolor" = "#333333"
|
|
44
|
+
"xtick.color" = "#777777"
|
|
45
|
+
"ytick.color" = "#777777"
|
|
46
|
+
"grid.color" = "#eeeeee"
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Reza Jelveh
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from typer.testing import CliRunner
|
|
6
|
+
|
|
7
|
+
from decktile.cli import app
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_build_pdf_and_odp_together(tmp_path):
|
|
11
|
+
"""--odp used to return before the --pdf step, silently skipping the PDF."""
|
|
12
|
+
deck = tmp_path / "d.md"
|
|
13
|
+
deck.write_text("---\ntitle: T\n---\n\n## Slide\n\nBody.\n")
|
|
14
|
+
result = CliRunner().invoke(app, ["--pdf", "--odp", "--output-dir", str(tmp_path), str(deck)])
|
|
15
|
+
assert result.exit_code == 0, result.output
|
|
16
|
+
assert (tmp_path / "d.odp").stat().st_size > 0
|
|
17
|
+
assert (tmp_path / "d.pdf").stat().st_size > 0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
DECK = "---\ntitle: T\n---\n\n## Slide\n\nBody.\n"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_main_missing_file_reports_error_and_exits_1(tmp_path):
|
|
24
|
+
result = CliRunner().invoke(app, [str(tmp_path / "nope.md")])
|
|
25
|
+
assert result.exit_code == 1
|
|
26
|
+
assert "nope.md: no such file" in result.output
|
|
27
|
+
assert result.exception is None or isinstance(result.exception, SystemExit)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_main_quoted_glob_builds_each_deck_once(tmp_path, monkeypatch):
|
|
31
|
+
"""'**/*.md' must not rebuild decks reached again through the source
|
|
32
|
+
symlinks decktile puts in every dist/ dir."""
|
|
33
|
+
(tmp_path / "sub").mkdir()
|
|
34
|
+
for p in ("a.md", "b.md", "sub/c.md"):
|
|
35
|
+
(tmp_path / p).write_text(DECK)
|
|
36
|
+
monkeypatch.chdir(tmp_path)
|
|
37
|
+
runner = CliRunner()
|
|
38
|
+
assert runner.invoke(app, ["**/*.md"]).exit_code == 0 # creates dist/ symlinks
|
|
39
|
+
result = runner.invoke(app, ["**/*.md"])
|
|
40
|
+
assert result.exit_code == 0, result.output
|
|
41
|
+
assert sorted(ln.split()[1] for ln in result.output.splitlines() if ln.startswith("Wrote")) == [
|
|
42
|
+
"dist/a.html",
|
|
43
|
+
"dist/b.html",
|
|
44
|
+
"sub/dist/c.html",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_main_failing_file_does_not_stop_the_rest(tmp_path):
|
|
49
|
+
(tmp_path / "bad.md").write_text("---\ntitle: [bad\n---\n\n## X\n")
|
|
50
|
+
(tmp_path / "good.md").write_text(DECK)
|
|
51
|
+
result = CliRunner().invoke(
|
|
52
|
+
app, ["-o", str(tmp_path / "out"), str(tmp_path / "bad.md"), str(tmp_path / "missing.md"), str(tmp_path / "good.md")]
|
|
53
|
+
)
|
|
54
|
+
assert result.exit_code == 1
|
|
55
|
+
assert "bad.md:" in result.output and "missing.md: no such file" in result.output
|
|
56
|
+
assert (tmp_path / "out" / "good.html").exists()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_seaborn_theme_without_chart_libraries(monkeypatch):
|
|
60
|
+
"""seaborn_theme in frontmatter must not crash a build when matplotlib isn't installed."""
|
|
61
|
+
import builtins
|
|
62
|
+
|
|
63
|
+
from decktile.render import seaborn as sb
|
|
64
|
+
|
|
65
|
+
real_import = builtins.__import__
|
|
66
|
+
|
|
67
|
+
def no_plot(name, *a, **k):
|
|
68
|
+
if name.split(".")[0] in ("matplotlib", "seaborn"):
|
|
69
|
+
raise ImportError(name)
|
|
70
|
+
return real_import(name, *a, **k)
|
|
71
|
+
|
|
72
|
+
monkeypatch.setattr(builtins, "__import__", no_plot)
|
|
73
|
+
sb.set_theme("default") # must not raise
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _make_theme(tmp_path):
|
|
77
|
+
from decktile.cli import theme_app
|
|
78
|
+
|
|
79
|
+
result = CliRunner().invoke(theme_app, ["create", str(tmp_path / "themes" / "acme")])
|
|
80
|
+
assert result.exit_code == 0, result.output
|
|
81
|
+
css = tmp_path / "themes" / "acme" / "theme.css"
|
|
82
|
+
css.write_text(css.read_text() + '\nsection { background-image: url("assets/bg.png"); }\n.acme-marker { color: red; }\n')
|
|
83
|
+
return css
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_theme_folder_from_frontmatter_replaces_theme_and_rebases_assets(tmp_path):
|
|
87
|
+
"""A theme folder's url("assets/...") must resolve from dist/, which sees the
|
|
88
|
+
deck folder through symlinks: the path is rebased onto the deck folder."""
|
|
89
|
+
_make_theme(tmp_path)
|
|
90
|
+
deck = tmp_path / "d.deck.md"
|
|
91
|
+
deck.write_text("---\ntheme: themes/acme\n---\n\n## Slide\n\nBody.\n")
|
|
92
|
+
result = CliRunner().invoke(app, [str(deck)])
|
|
93
|
+
assert result.exit_code == 0, result.output
|
|
94
|
+
html = (tmp_path / "dist" / "d.html").read_text()
|
|
95
|
+
assert ".acme-marker" in html
|
|
96
|
+
assert 'url("themes/acme/assets/bg.png")' in html
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_theme_option_overrides_frontmatter_theme(tmp_path):
|
|
100
|
+
_make_theme(tmp_path)
|
|
101
|
+
deck = tmp_path / "d.deck.md"
|
|
102
|
+
deck.write_text("---\ntheme: kubecon_japan\n---\n\n## Slide\n")
|
|
103
|
+
result = CliRunner().invoke(app, ["--theme", str(tmp_path / "themes" / "acme"), str(deck)])
|
|
104
|
+
assert result.exit_code == 0, result.output
|
|
105
|
+
html = (tmp_path / "dist" / "d.html").read_text()
|
|
106
|
+
assert ".acme-marker" in html and "KubeCon" not in html
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_theme_folder_outside_deck_folder_is_an_error(tmp_path):
|
|
110
|
+
_make_theme(tmp_path)
|
|
111
|
+
(tmp_path / "decks").mkdir()
|
|
112
|
+
deck = tmp_path / "decks" / "d.deck.md"
|
|
113
|
+
deck.write_text(DECK)
|
|
114
|
+
result = CliRunner().invoke(app, ["--theme", str(tmp_path / "themes" / "acme"), str(deck)])
|
|
115
|
+
assert result.exit_code == 1
|
|
116
|
+
assert "must be inside the deck folder" in result.output
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_theme_create_refuses_non_empty_folder(tmp_path):
|
|
120
|
+
from decktile.cli import theme_app
|
|
121
|
+
|
|
122
|
+
(tmp_path / "acme").mkdir()
|
|
123
|
+
(tmp_path / "acme" / "theme.css").write_text("keep me")
|
|
124
|
+
result = CliRunner().invoke(theme_app, ["create", str(tmp_path / "acme")])
|
|
125
|
+
assert result.exit_code == 1
|
|
126
|
+
assert (tmp_path / "acme" / "theme.css").read_text() == "keep me"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_created_theme_preview_deck_builds_against_its_folder(tmp_path):
|
|
130
|
+
"""The scaffold must be usable as-is: its preview deck selects the folder
|
|
131
|
+
with `theme: .` and every block in it renders (no diagram fallback)."""
|
|
132
|
+
from decktile.cli import theme_app
|
|
133
|
+
|
|
134
|
+
folder = tmp_path / "acme"
|
|
135
|
+
assert CliRunner().invoke(theme_app, ["create", str(folder)]).exit_code == 0
|
|
136
|
+
css = folder / "theme.css"
|
|
137
|
+
css.write_text(css.read_text() + "\n.acme-marker { color: red; }\n")
|
|
138
|
+
result = CliRunner().invoke(app, [str(folder / "preview.deck.md")])
|
|
139
|
+
assert result.exit_code == 0, result.output
|
|
140
|
+
html = (folder / "dist" / "preview.html").read_text()
|
|
141
|
+
assert ".acme-marker" in html
|
|
142
|
+
assert "pdg-fallback" not in html
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_mistyped_theme_folder_is_an_error_not_the_default_theme(tmp_path):
|
|
146
|
+
_make_theme(tmp_path)
|
|
147
|
+
deck = tmp_path / "d.deck.md"
|
|
148
|
+
deck.write_text("---\ntheme: themes/acmee\n---\n\n## Slide\n")
|
|
149
|
+
result = CliRunner().invoke(app, [str(deck)])
|
|
150
|
+
assert result.exit_code == 1
|
|
151
|
+
assert "no theme.css" in result.output
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_card_h4_is_a_label_in_place(tmp_path):
|
|
155
|
+
deck = tmp_path / "d.deck.md"
|
|
156
|
+
deck.write_text("---\ntitle: T\n---\n\n## S\n\n::: card\n### Head\nfirst\n#### Label\nsecond\n:::\n")
|
|
157
|
+
assert CliRunner().invoke(app, [str(deck)]).exit_code == 0
|
|
158
|
+
html = (tmp_path / "dist" / "d.html").read_text()
|
|
159
|
+
assert "<p>first</p>\n<h4>Label</h4>\n<p>second</p>" in html
|
decktile-0.3.7/tests/test_cli.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: 2026 Reza Jelveh
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
|
|
5
|
-
from typer.testing import CliRunner
|
|
6
|
-
|
|
7
|
-
from decktile.cli import app
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_build_pdf_and_odp_together(tmp_path):
|
|
11
|
-
"""--odp used to return before the --pdf step, silently skipping the PDF."""
|
|
12
|
-
deck = tmp_path / "d.md"
|
|
13
|
-
deck.write_text("---\ntitle: T\n---\n\n## Slide\n\nBody.\n")
|
|
14
|
-
result = CliRunner().invoke(app, ["--pdf", "--odp", "--output-dir", str(tmp_path), str(deck)])
|
|
15
|
-
assert result.exit_code == 0, result.output
|
|
16
|
-
assert (tmp_path / "d.odp").stat().st_size > 0
|
|
17
|
-
assert (tmp_path / "d.pdf").stat().st_size > 0
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
DECK = "---\ntitle: T\n---\n\n## Slide\n\nBody.\n"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def test_main_missing_file_reports_error_and_exits_1(tmp_path):
|
|
24
|
-
result = CliRunner().invoke(app, [str(tmp_path / "nope.md")])
|
|
25
|
-
assert result.exit_code == 1
|
|
26
|
-
assert "nope.md: no such file" in result.output
|
|
27
|
-
assert result.exception is None or isinstance(result.exception, SystemExit)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def test_main_quoted_glob_builds_each_deck_once(tmp_path, monkeypatch):
|
|
31
|
-
"""'**/*.md' must not rebuild decks reached again through the source
|
|
32
|
-
symlinks decktile puts in every dist/ dir."""
|
|
33
|
-
(tmp_path / "sub").mkdir()
|
|
34
|
-
for p in ("a.md", "b.md", "sub/c.md"):
|
|
35
|
-
(tmp_path / p).write_text(DECK)
|
|
36
|
-
monkeypatch.chdir(tmp_path)
|
|
37
|
-
runner = CliRunner()
|
|
38
|
-
assert runner.invoke(app, ["**/*.md"]).exit_code == 0 # creates dist/ symlinks
|
|
39
|
-
result = runner.invoke(app, ["**/*.md"])
|
|
40
|
-
assert result.exit_code == 0, result.output
|
|
41
|
-
assert sorted(ln.split()[1] for ln in result.output.splitlines() if ln.startswith("Wrote")) == [
|
|
42
|
-
"dist/a.html",
|
|
43
|
-
"dist/b.html",
|
|
44
|
-
"sub/dist/c.html",
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_main_failing_file_does_not_stop_the_rest(tmp_path):
|
|
49
|
-
(tmp_path / "bad.md").write_text("---\ntitle: [bad\n---\n\n## X\n")
|
|
50
|
-
(tmp_path / "good.md").write_text(DECK)
|
|
51
|
-
result = CliRunner().invoke(
|
|
52
|
-
app, ["-o", str(tmp_path / "out"), str(tmp_path / "bad.md"), str(tmp_path / "missing.md"), str(tmp_path / "good.md")]
|
|
53
|
-
)
|
|
54
|
-
assert result.exit_code == 1
|
|
55
|
-
assert "bad.md:" in result.output and "missing.md: no such file" in result.output
|
|
56
|
-
assert (tmp_path / "out" / "good.html").exists()
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_seaborn_theme_without_chart_libraries(monkeypatch):
|
|
60
|
-
"""seaborn_theme in frontmatter must not crash a build when matplotlib isn't installed."""
|
|
61
|
-
import builtins
|
|
62
|
-
|
|
63
|
-
from decktile.render import seaborn as sb
|
|
64
|
-
|
|
65
|
-
real_import = builtins.__import__
|
|
66
|
-
|
|
67
|
-
def no_plot(name, *a, **k):
|
|
68
|
-
if name.split(".")[0] in ("matplotlib", "seaborn"):
|
|
69
|
-
raise ImportError(name)
|
|
70
|
-
return real_import(name, *a, **k)
|
|
71
|
-
|
|
72
|
-
monkeypatch.setattr(builtins, "__import__", no_plot)
|
|
73
|
-
sb.set_theme("default") # must not raise
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|