Skip to content

Commit bdf9fbe

Browse files
committed
fix: remove superfluous theme/color mechanism
This is technically a breaking change but trivial to resolve in configs: No more special implicit treatment of "theme" to resolve a "style". Just use regular variables like ``` style: primary_text_colour: {{ theme.off_black }} secondary_text_colour: {{ theme.off_white }} theme: off_black: "#2d2a2b" off_white: "#f5f5f5" ```
1 parent a2c2b62 commit bdf9fbe

File tree

3 files changed

+3
-31
lines changed

3 files changed

+3
-31
lines changed

src/pdfbaker/config/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ class ImageSpec(PathSpec):
8989
data: str | None = None
9090

9191

92-
class StyleDict(BaseModel):
93-
"""Style configuration."""
94-
95-
highlight_color: str | None = None
96-
97-
9892
class Directories(BaseModel):
9993
"""Directories configuration."""
10094

src/pdfbaker/render.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import jinja2
1111

1212
from . import processing
13-
from .config import ImageSpec, StyleDict
13+
from .config import ImageSpec
1414

1515
__all__ = [
1616
"create_env",
@@ -94,24 +94,12 @@ def create_env(
9494
def prepare_template_context(
9595
context: dict[str], images_dir: Path | None = None
9696
) -> dict[str]:
97-
"""Prepare template context with variables/styles/images
98-
99-
Resolves variables, styles and encodes images.
97+
"""Encode images for template context
10098
10199
Args:
102-
config: Configuration with optional styles and images
100+
config: Configuration with optional images
103101
images_dir: Directory containing images to encode
104102
"""
105-
# Resolve style references to actual theme colors
106-
if "style" in context and "theme" in context:
107-
style = context["style"]
108-
theme = context["theme"]
109-
resolved_style: StyleDict = {}
110-
for key, value in style.items():
111-
resolved_style[key] = theme[value]
112-
context["style"] = resolved_style
113-
114-
# Process image references
115103
if context.get("images") is not None:
116104
context["images"] = encode_images(context["images"], images_dir)
117105

tests/test_render.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ def test_highlighting_template_no_style() -> None:
5151

5252

5353
# Context preparation tests
54-
def test_prepare_template_context_styles() -> None:
55-
"""Test style resolution in template context."""
56-
config = {
57-
"style": {"color": "primary"},
58-
"theme": {"primary": "#ff0000"},
59-
}
60-
context = prepare_template_context(config)
61-
assert context["style"]["color"] == "#ff0000"
62-
63-
6454
def test_prepare_template_context_images(tmp_path: Path) -> None:
6555
"""Test image processing in template context."""
6656
# Create test image

0 commit comments

Comments
 (0)