Skip to content

feat: add per-slide background color via comment command#826

Open
alycda wants to merge 5 commits intomfontanini:masterfrom
alycda:claude/slide-background-color-PvpZ0
Open

feat: add per-slide background color via comment command#826
alycda wants to merge 5 commits intomfontanini:masterfrom
alycda:claude/slide-background-color-PvpZ0

Conversation

@alycda
Copy link
Copy Markdown
Contributor

@alycda alycda commented Jan 23, 2026

Add support for setting a background color on individual slides using the <!-- background_color: <color> --> comment command. This allows users to customize specific slides with different background colors.

The color can be specified as:

  • A hex RGB value (e.g., ff0000 for red)
  • A named color (e.g., red, blue)
  • A palette reference (e.g., palette:primary)

When the command is encountered, the slide is re-cleared with the new background color, ensuring all subsequent content renders on that background.

claude and others added 3 commits January 23, 2026 21:33
Add support for setting a background color on individual slides using
the `<!-- background_color: <color> -->` comment command. This allows
users to customize specific slides with different background colors.

The color can be specified as:
- A hex RGB value (e.g., `ff0000` for red)
- A named color (e.g., `red`, `blue`)
- A palette reference (e.g., `palette:primary`)

When the command is encountered, the slide is re-cleared with the new
background color, ensuring all subsequent content renders on that
background.
Instead of applying background color immediately when the command is
encountered (which would clear content rendered before the command),
now the background color is stored and applied retroactively to all
SetColors operations in the slide when the slide is terminated.

This ensures the entire slide uses the custom background color,
regardless of where the `<!-- background_color: xxx -->` command
appears in the slide content.
Copy link
Copy Markdown
Owner

@mfontanini mfontanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea but the approach won't work. I'm not sure what's the best way, possibly storing the initial color and only pushing it later. Or only changing the first SetColors although I don't know if that'll break something.

// so the entire slide uses the custom background
if let Some(bg_color) = self.slide_state.background_color {
for op in &mut operations {
if let RenderOperation::SetColors(colors) = op {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right. It's possible there's more than the initial SetColors inside a slide. e.g. a <span ... that sets the color.

@alycda
Copy link
Copy Markdown
Contributor Author

alycda commented Jan 24, 2026

I like the idea but the approach won't work. I'm not sure what's the best way, possibly storing the initial color and only pushing it later. Or only changing the first SetColors although I don't know if that'll break something.

it's working for me locally. The first commit clobbered the slide title / anything before the comment, but the current state is working as expected, let me try to upload an asciinema

@alycda
Copy link
Copy Markdown
Contributor Author

alycda commented Jan 24, 2026

not sure how helpful this is: https://asciinema.org/a/llefFhnKLQfsPJIs

---
title: slide background color override
theme:
    name: light
---

Who am I?
===

<!-- slide_background_color: black --> 

<!-- end_slide -->

Advent of Code 2024
===

<!-- slide_background_color: 0f0f23 --> 

I recorded it in kitty. The slides render as expected but the asciicast clearly didn't render the slide content, just the bg color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants