mmdflux 2.1.0

Render Mermaid diagrams as Unicode text, ASCII, SVG, and MMDS JSON.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
//! Internal SVG theme resolution and CSS metadata helpers.
//!
//! Runtime owns whether a diagram is themed at all. When it chooses to apply a
//! theme, this module turns the public facade config into concrete SVG slot
//! colors, derived renderer roles, and optional browser-only CSS metadata.

/// Render-owned SVG theme mode.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub(crate) enum SvgThemeRenderMode {
    #[default]
    Static,
    Dynamic,
}

/// Render-owned SVG theme input spec.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub(crate) struct SvgThemeSpec {
    pub name: Option<String>,
    pub mode: SvgThemeRenderMode,
    pub bg: Option<String>,
    pub fg: Option<String>,
    pub line: Option<String>,
    pub accent: Option<String>,
    pub muted: Option<String>,
    pub surface: Option<String>,
    pub border: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct SvgThemeError {
    pub message: String,
}

impl std::fmt::Display for SvgThemeError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.message)
    }
}

impl std::error::Error for SvgThemeError {}

const MIX_NODE_FILL: f64 = 0.03;
const MIX_GROUP_HEADER: f64 = 0.05;
const MIX_KEY_BADGE: f64 = 0.10;
const MIX_INNER_STROKE: f64 = 0.12;
const MIX_NODE_STROKE: f64 = 0.20;
const MIX_TEXT_FAINT: f64 = 0.25;
const MIX_TEXT_MUTED: f64 = 0.40;
const MIX_LINE: f64 = 0.50;
const MIX_TEXT_SECONDARY: f64 = 0.60;
const MIX_ARROW: f64 = 0.85;

const DEFAULT_BG: &str = "#ffffff";
const DEFAULT_FG: &str = "#27272a";

#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub(crate) struct SvgRootStyle {
    pub background_color: Option<String>,
    pub css_variables: Vec<(String, String)>,
    pub style_block: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ResolvedSvgTheme {
    pub canonical_name: Option<String>,
    pub slots: ResolvedThemeSlots,
    pub roles: DerivedThemeRoles,
    pub dynamic: Option<DynamicThemeMetadata>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ResolvedThemeSlots {
    pub bg: String,
    pub fg: String,
    pub line: String,
    pub accent: String,
    pub muted: String,
    pub surface: String,
    pub border: String,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct DerivedThemeRoles {
    pub background: String,
    pub text: String,
    pub text_secondary: String,
    pub text_muted: String,
    pub text_faint: String,
    pub line: String,
    pub arrow: String,
    pub node_fill: String,
    pub node_stroke: String,
    pub group_fill: String,
    pub group_header: String,
    pub inner_stroke: String,
    pub key_badge: String,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct DynamicThemeMetadata {
    pub root_style: SvgRootStyle,
    pub style_block: String,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct NamedSvgThemeDefinition {
    pub canonical_name: &'static str,
    pub seed: ThemeSeed,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct ThemeSeed {
    pub bg: &'static str,
    pub fg: &'static str,
    pub line: Option<&'static str>,
    pub accent: Option<&'static str>,
    pub muted: Option<&'static str>,
    pub surface: Option<&'static str>,
    pub border: Option<&'static str>,
}

const BEAUTIFUL_MERMAID_THEMES: &[NamedSvgThemeDefinition] = &[
    named_theme(
        "zinc-light",
        ThemeSeed {
            bg: "#ffffff",
            fg: "#27272a",
            line: None,
            accent: None,
            muted: None,
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "zinc-dark",
        ThemeSeed {
            bg: "#18181b",
            fg: "#fafafa",
            line: None,
            accent: None,
            muted: None,
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "tokyo-night",
        ThemeSeed {
            bg: "#1a1b26",
            fg: "#a9b1d6",
            line: Some("#3d59a1"),
            accent: Some("#7aa2f7"),
            muted: Some("#565f89"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "tokyo-night-storm",
        ThemeSeed {
            bg: "#24283b",
            fg: "#a9b1d6",
            line: Some("#3d59a1"),
            accent: Some("#7aa2f7"),
            muted: Some("#565f89"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "tokyo-night-light",
        ThemeSeed {
            bg: "#d5d6db",
            fg: "#343b58",
            line: Some("#34548a"),
            accent: Some("#34548a"),
            muted: Some("#9699a3"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "catppuccin-mocha",
        ThemeSeed {
            bg: "#1e1e2e",
            fg: "#cdd6f4",
            line: Some("#585b70"),
            accent: Some("#cba6f7"),
            muted: Some("#6c7086"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "catppuccin-latte",
        ThemeSeed {
            bg: "#eff1f5",
            fg: "#4c4f69",
            line: Some("#9ca0b0"),
            accent: Some("#8839ef"),
            muted: Some("#9ca0b0"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "nord",
        ThemeSeed {
            bg: "#2e3440",
            fg: "#d8dee9",
            line: Some("#4c566a"),
            accent: Some("#88c0d0"),
            muted: Some("#616e88"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "nord-light",
        ThemeSeed {
            bg: "#eceff4",
            fg: "#2e3440",
            line: Some("#aab1c0"),
            accent: Some("#5e81ac"),
            muted: Some("#7b88a1"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "dracula",
        ThemeSeed {
            bg: "#282a36",
            fg: "#f8f8f2",
            line: Some("#6272a4"),
            accent: Some("#bd93f9"),
            muted: Some("#6272a4"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "github-light",
        ThemeSeed {
            bg: "#ffffff",
            fg: "#1f2328",
            line: Some("#d1d9e0"),
            accent: Some("#0969da"),
            muted: Some("#59636e"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "github-dark",
        ThemeSeed {
            bg: "#0d1117",
            fg: "#e6edf3",
            line: Some("#3d444d"),
            accent: Some("#4493f8"),
            muted: Some("#9198a1"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "solarized-light",
        ThemeSeed {
            bg: "#fdf6e3",
            fg: "#657b83",
            line: Some("#93a1a1"),
            accent: Some("#268bd2"),
            muted: Some("#93a1a1"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "solarized-dark",
        ThemeSeed {
            bg: "#002b36",
            fg: "#839496",
            line: Some("#586e75"),
            accent: Some("#268bd2"),
            muted: Some("#586e75"),
            surface: None,
            border: None,
        },
    ),
    named_theme(
        "one-dark",
        ThemeSeed {
            bg: "#282c34",
            fg: "#abb2bf",
            line: Some("#4b5263"),
            accent: Some("#c678dd"),
            muted: Some("#5c6370"),
            surface: None,
            border: None,
        },
    ),
];

const MERMAID_THEMES: &[NamedSvgThemeDefinition] = &[
    named_theme(
        "default",
        ThemeSeed {
            bg: "#ffffff",
            fg: "#333333",
            line: Some("#333333"),
            accent: Some("#333333"),
            muted: Some("#666666"),
            surface: Some("#ececff"),
            border: Some("#9370db"),
        },
    ),
    named_theme(
        "dark",
        ThemeSeed {
            bg: "#333333",
            fg: "#cccccc",
            line: Some("#d3d3d3"),
            accent: Some("#d3d3d3"),
            muted: Some("#cccccc"),
            surface: Some("#1f2020"),
            border: Some("#cccccc"),
        },
    ),
    named_theme(
        "forest",
        ThemeSeed {
            bg: "#ffffff",
            fg: "#333333",
            line: Some("#13540c"),
            accent: Some("#13540c"),
            muted: Some("#333333"),
            surface: Some("#cde498"),
            border: Some("#13540c"),
        },
    ),
    named_theme(
        "neutral",
        ThemeSeed {
            bg: "#ffffff",
            fg: "#333333",
            line: Some("#666666"),
            accent: Some("#333333"),
            muted: Some("#333333"),
            surface: Some("#eeeeee"),
            border: Some("#999999"),
        },
    ),
];

const fn named_theme(canonical_name: &'static str, seed: ThemeSeed) -> NamedSvgThemeDefinition {
    NamedSvgThemeDefinition {
        canonical_name,
        seed,
    }
}

pub(crate) fn resolve_theme_name(name: &str) -> Result<NamedSvgThemeDefinition, SvgThemeError> {
    let normalized = name.trim().to_ascii_lowercase();
    let canonical = match normalized.as_str() {
        "base" => "default",
        other => other,
    };

    BEAUTIFUL_MERMAID_THEMES
        .iter()
        .chain(MERMAID_THEMES.iter())
        .copied()
        .find(|theme| theme.canonical_name == canonical)
        .ok_or_else(|| SvgThemeError {
            message: format!("unknown SVG theme `{name}`"),
        })
}

pub(crate) fn resolve_svg_theme(config: &SvgThemeSpec) -> Result<ResolvedSvgTheme, SvgThemeError> {
    let named = config.name.as_deref().map(resolve_theme_name).transpose()?;

    let bg = resolve_slot(
        config.bg.as_deref(),
        named.map(|theme| theme.seed.bg),
        DEFAULT_BG,
    )?;
    let fg = resolve_slot(
        config.fg.as_deref(),
        named.map(|theme| theme.seed.fg),
        DEFAULT_FG,
    )?;

    let slots = ResolvedThemeSlots {
        bg: bg.clone(),
        fg: fg.clone(),
        line: resolve_optional_slot(
            config.line.as_deref(),
            named.and_then(|theme| theme.seed.line),
            &fg,
            &bg,
            MIX_LINE,
        )?,
        accent: resolve_optional_slot(
            config.accent.as_deref(),
            named.and_then(|theme| theme.seed.accent),
            &fg,
            &bg,
            MIX_ARROW,
        )?,
        muted: resolve_optional_slot(
            config.muted.as_deref(),
            named.and_then(|theme| theme.seed.muted),
            &fg,
            &bg,
            MIX_TEXT_MUTED,
        )?,
        surface: resolve_optional_slot(
            config.surface.as_deref(),
            named.and_then(|theme| theme.seed.surface),
            &fg,
            &bg,
            MIX_NODE_FILL,
        )?,
        border: resolve_optional_slot(
            config.border.as_deref(),
            named.and_then(|theme| theme.seed.border),
            &fg,
            &bg,
            MIX_NODE_STROKE,
        )?,
    };

    let roles = DerivedThemeRoles {
        background: slots.bg.clone(),
        text: slots.fg.clone(),
        text_secondary: mix_hex(&slots.fg, &slots.bg, MIX_TEXT_SECONDARY)?,
        text_muted: slots.muted.clone(),
        text_faint: mix_hex(&slots.fg, &slots.bg, MIX_TEXT_FAINT)?,
        line: slots.line.clone(),
        arrow: slots.accent.clone(),
        node_fill: slots.surface.clone(),
        node_stroke: slots.border.clone(),
        group_fill: slots.bg.clone(),
        group_header: mix_hex(&slots.fg, &slots.bg, MIX_GROUP_HEADER)?,
        inner_stroke: mix_hex(&slots.fg, &slots.bg, MIX_INNER_STROKE)?,
        key_badge: mix_hex(&slots.fg, &slots.bg, MIX_KEY_BADGE)?,
    };

    let dynamic = if matches!(config.mode, SvgThemeRenderMode::Dynamic) {
        let style_block = build_dynamic_style_block();
        Some(DynamicThemeMetadata {
            root_style: SvgRootStyle {
                background_color: Some(slots.bg.clone()),
                css_variables: vec![
                    ("--bg".into(), slots.bg.clone()),
                    ("--fg".into(), slots.fg.clone()),
                    ("--line".into(), slots.line.clone()),
                    ("--accent".into(), slots.accent.clone()),
                    ("--muted".into(), slots.muted.clone()),
                    ("--surface".into(), slots.surface.clone()),
                    ("--border".into(), slots.border.clone()),
                ],
                style_block: Some(style_block.clone()),
            },
            style_block,
        })
    } else {
        None
    };

    Ok(ResolvedSvgTheme {
        canonical_name: named.map(|theme| theme.canonical_name.to_string()),
        slots,
        roles,
        dynamic,
    })
}

fn resolve_slot(
    explicit: Option<&str>,
    named: Option<&str>,
    default: &str,
) -> Result<String, SvgThemeError> {
    normalize_hex_color(explicit.or(named).unwrap_or(default))
}

fn resolve_optional_slot(
    explicit: Option<&str>,
    named: Option<&str>,
    fg: &str,
    bg: &str,
    mix_pct: f64,
) -> Result<String, SvgThemeError> {
    match explicit.or(named) {
        Some(color) => normalize_hex_color(color),
        None => mix_hex(fg, bg, mix_pct),
    }
}

fn normalize_hex_color(input: &str) -> Result<String, SvgThemeError> {
    let parsed = parse_hex_color(input)?;
    Ok(format!(
        "#{:02x}{:02x}{:02x}",
        parsed[0], parsed[1], parsed[2]
    ))
}

fn parse_hex_color(input: &str) -> Result<[u8; 3], SvgThemeError> {
    let value = input.trim();
    let raw = value.strip_prefix('#').ok_or_else(|| SvgThemeError {
        message: format!("invalid SVG theme color `{input}`"),
    })?;

    match raw.len() {
        3 => {
            let mut out = [0_u8; 3];
            for (idx, ch) in raw.chars().enumerate() {
                let digit = ch.to_digit(16).ok_or_else(|| SvgThemeError {
                    message: format!("invalid SVG theme color `{input}`"),
                })? as u8;
                out[idx] = digit * 17;
            }
            Ok(out)
        }
        6 => {
            let mut out = [0_u8; 3];
            for (idx, chunk) in raw.as_bytes().chunks_exact(2).enumerate() {
                let chunk = std::str::from_utf8(chunk).map_err(|_| SvgThemeError {
                    message: format!("invalid SVG theme color `{input}`"),
                })?;
                out[idx] = u8::from_str_radix(chunk, 16).map_err(|_| SvgThemeError {
                    message: format!("invalid SVG theme color `{input}`"),
                })?;
            }
            Ok(out)
        }
        _ => Err(SvgThemeError {
            message: format!("invalid SVG theme color `{input}`"),
        }),
    }
}

fn mix_hex(fg: &str, bg: &str, pct: f64) -> Result<String, SvgThemeError> {
    let fg = parse_hex_color(fg)?;
    let bg = parse_hex_color(bg)?;
    let mix_channel =
        |fg: u8, bg: u8| -> u8 { ((fg as f64 * pct) + (bg as f64 * (1.0 - pct))).round() as u8 };

    Ok(format!(
        "#{:02x}{:02x}{:02x}",
        mix_channel(fg[0], bg[0]),
        mix_channel(fg[1], bg[1]),
        mix_channel(fg[2], bg[2]),
    ))
}

fn build_dynamic_style_block() -> String {
    [
        "svg {",
        "  --_text: var(--fg);",
        "  --_text-sec: color-mix(in srgb, var(--fg) 60%, var(--bg));",
        "  --_text-muted: var(--muted);",
        "  --_text-faint: color-mix(in srgb, var(--fg) 25%, var(--bg));",
        "  --_line: var(--line);",
        "  --_arrow: var(--accent);",
        "  --_node-fill: var(--surface);",
        "  --_node-stroke: var(--border);",
        "  --_group-fill: var(--bg);",
        "  --_group-hdr: color-mix(in srgb, var(--fg) 5%, var(--bg));",
        "  --_inner-stroke: color-mix(in srgb, var(--fg) 12%, var(--bg));",
        "  --_key-badge: color-mix(in srgb, var(--fg) 10%, var(--bg));",
        "}",
    ]
    .join("\n")
}

#[cfg(test)]
mod tests {
    use super::{SvgThemeRenderMode, SvgThemeSpec, resolve_svg_theme, resolve_theme_name};

    #[test]
    fn named_mermaid_aliases_resolve_to_expected_base_theme() {
        assert_eq!(
            resolve_theme_name("base").unwrap().canonical_name,
            "default"
        );
        assert_eq!(resolve_theme_name("dark").unwrap().canonical_name, "dark");
        assert_eq!(
            resolve_theme_name("forest").unwrap().canonical_name,
            "forest"
        );
        assert_eq!(
            resolve_theme_name("neutral").unwrap().canonical_name,
            "neutral"
        );
    }

    #[test]
    fn beautiful_mermaid_builtin_palette_values_are_pinned() {
        let resolved = resolve_theme_name("tokyo-night").unwrap();

        assert_eq!(resolved.seed.bg, "#1a1b26");
        assert_eq!(resolved.seed.fg, "#a9b1d6");
        assert_eq!(resolved.seed.line, Some("#3d59a1"));
        assert_eq!(resolved.seed.accent, Some("#7aa2f7"));
        assert_eq!(resolved.seed.muted, Some("#565f89"));
    }

    #[test]
    fn slot_overrides_apply_on_top_of_named_theme() {
        let resolved = resolve_svg_theme(&SvgThemeSpec {
            name: Some("dark".into()),
            accent: Some("#ff00aa".into()),
            ..Default::default()
        })
        .unwrap();

        assert_eq!(resolved.canonical_name.as_deref(), Some("dark"));
        assert_eq!(resolved.slots.accent, "#ff00aa");
    }

    #[test]
    fn invalid_theme_names_fail_cleanly() {
        let err = resolve_theme_name("not-a-real-theme").unwrap_err();
        assert!(err.message.contains("unknown SVG theme"));
    }

    #[test]
    fn invalid_slot_color_tokens_fail_cleanly() {
        let err = resolve_svg_theme(&SvgThemeSpec {
            bg: Some("not-a-color".into()),
            ..Default::default()
        })
        .unwrap_err();

        assert!(err.message.contains("invalid SVG theme color"));
    }

    #[test]
    fn derived_roles_follow_the_approved_mix_ratios() {
        let resolved = resolve_svg_theme(&SvgThemeSpec {
            bg: Some("#ffffff".into()),
            fg: Some("#27272a".into()),
            ..Default::default()
        })
        .unwrap();

        assert_eq!(resolved.slots.line, "#939395");
        assert_eq!(resolved.slots.accent, "#47474a");
        assert_eq!(resolved.slots.muted, "#a9a9aa");
        assert_eq!(resolved.slots.surface, "#f9f9f9");
        assert_eq!(resolved.slots.border, "#d4d4d4");
        assert_eq!(resolved.roles.text, "#27272a");
        assert_eq!(resolved.roles.text_secondary, "#7d7d7f");
        assert_eq!(resolved.roles.text_muted, "#a9a9aa");
        assert_eq!(resolved.roles.text_faint, "#c9c9ca");
        assert_eq!(resolved.roles.group_header, "#f4f4f4");
        assert_eq!(resolved.roles.inner_stroke, "#e5e5e5");
        assert_eq!(resolved.roles.key_badge, "#e9e9ea");
    }

    #[test]
    fn dynamic_mode_includes_public_root_variables_and_css_payload() {
        let resolved = resolve_svg_theme(&SvgThemeSpec {
            mode: SvgThemeRenderMode::Dynamic,
            ..Default::default()
        })
        .unwrap();

        let dynamic = resolved
            .dynamic
            .expect("dynamic metadata should be present");
        let root_vars: Vec<_> = dynamic
            .root_style
            .css_variables
            .iter()
            .map(|(name, value)| format!("{name}:{value}"))
            .collect();

        assert!(root_vars.contains(&"--bg:#ffffff".to_string()));
        assert!(root_vars.contains(&"--fg:#27272a".to_string()));
        assert!(root_vars.contains(&"--line:#939395".to_string()));
        assert!(root_vars.contains(&"--accent:#47474a".to_string()));
        assert!(root_vars.contains(&"--muted:#a9a9aa".to_string()));
        assert!(root_vars.contains(&"--surface:#f9f9f9".to_string()));
        assert!(root_vars.contains(&"--border:#d4d4d4".to_string()));
        assert!(dynamic.style_block.contains("--_text: var(--fg);"));
        assert!(dynamic.style_block.contains("--_line: var(--line);"));
        assert!(
            dynamic
                .style_block
                .contains("--_node-fill: var(--surface);")
        );
        assert!(
            dynamic
                .style_block
                .contains("--_node-stroke: var(--border);")
        );
    }
}