aws-samples / aws-samples/sample-spec-driven-presentation-maker
Token discipline: check inline directives ({{NNpt:...}} and {{#HEX:...}})
- Dominant language
- Python
- Stars
- 128
- Forks
- 10
- Avg merge
- 4d 40m
- Merged PRs (30d)
- 8
Description
---
title: "Token discipline: check inline directives ({{NNpt:...}} and {{#HEX:...}})"
---
## Problem
The fontSize token check (#133, follow-up #TBD) only validates `fontSize` as a JSON key. Font sizes and colors specified via inline directives inside `text` strings are not checked:
```json
{"type": "textbox", "fontSize": 16, "text": "{{22pt:big}} and {{#FF9900:orange}}"}
```
- `fontSize: 16` → checked ✓
- `{{22pt:big}}` → not checked ✗
- `{{#FF9900:orange}}` → not checked ✗
These inline directives are parsed at render time by `sdpm.utils.text.parse_styled_text` (line 70), which supports:
- `NNpt` (font size)
- `#RRGGBB` (color)
- `bold`, `italic`, `underline`
- `font=Name`
- `link:URL`
## Proposed solution
Add a second pass in `sdpm/checks/font_size.py` (and future `color.py`) that:
1. Walks all string values in the slide JSON
2. Extracts `{{attrs:text}}` patterns via the same regex used by `parse_styled_text`
3. Validates `NNpt` attrs against `--fs-*` tokens
4. Validates `#RRGGBB` attrs against `--color-*` / `--*` color tokens
Can reuse `_walk_font_sizes` pattern — extend to yield inline occurrences with a location like `page02(intro) elements.[0].text:inline`.
## Scope
- [ ] fontSize in inline directives
- [ ] hex color in inline directives
- [ ] hex color as JSON keys (separate but related — `color`, `fill`, `fontColor`, `iconColor`, etc.)
## References
- `skill/sdpm/utils/text.py:70` — `parse_styled_text` docstring
- `skill/sdpm/checks/font_size.py` — known limitation comment in `_walk_font_sizes`
- `skill/references/workflows/slide-json-spec.md:114` — inline directive spec
Contributor guide
Assessment
This issue has not been assessed yet.