feat: add per-slide background color via comment command#826
feat: add per-slide background color via comment command#826alycda wants to merge 5 commits intomfontanini:masterfrom
Conversation
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.
mfontanini
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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 |
|
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 |
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:
ff0000for red)red,blue)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.