Resource-box badge taller than its container
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in src/presentations/slides.py at add_resource_box_slide, especially the container-height calculation around line 353 and badge positioning around line 444. Run the supplied uv MRE through presentations.cli, inspect the generated .pptx, and confirm the single-row badge stays fully inside its rounded box while multi-row boxes remain unchanged.
Written by the indexing model from the issue text.
Description
Summary
On a resource-box slide, a box with a single row renders its gradient badge taller than the box — the badge sticks out above and below the rounded rectangle.
Impact
High — visibly broken layout on any one-row resource box (and any future short box). Affects the resource-box slide type with the default badge_height.
Environment
ms-presentationsversion: 0.1.6- Python version: 3.10+
- OS / version: reproduces on all (pure python-pptx geometry; verified on Windows 11)
- Install method: pip / from source
- Relevant deps (if Azure path): n/a — renders fully locally, no Azure
- Azure / model config: n/a
Steps to Reproduce
- Author a
resource-boxslide with at least one box that has a single row. - Keep the default
badge_height(1.1"). - Render the spec and open the
.pptx.
Minimal Reproducible Example (MRE)
# /// script
# requires-python = ">=3.10"
# dependencies = ["ms-presentations==0.1.6"]
# ///
"""Self-contained MRE — resource-box badge taller than its container.
Run with: uv run mse.py (no venv, no Azure, no network)
A single-row resource box renders its gradient badge taller than the box, so the
badge overflows above and below the rounded rectangle. The one-row "Learn" box
has a 0.85" container, shorter than the default 1.1" badge, so the centering
offset goes negative and the badge spills out top and bottom. Open the rendered
deck and compare the one-row "Learn" badge to its box — the deck is the only output.
"""
import os
import tempfile
from presentations.cli import main
SPEC = """\
---
title: Repro - Badge taller than container
output: Badge_Taller_Than_Container.pptx
style:
badge_height: 1.1
---
## [resource-box] Getting started
**Subtitle**: Resources
**Box**: Learn
- One Row Only | https://example.com/one
**Box**: Reference
- First Row | https://example.com/a
- Second Row | https://example.com/b
"""
with tempfile.TemporaryDirectory() as d:
spec_path = os.path.join(d, "minimal.spec.md")
with open(spec_path, "w", encoding="utf-8") as f:
f.write(SPEC)
main([spec_path, "-o", os.getcwd()]) # renders the deck into the PWD
uv run mse.py
Expected Behavior
The badge stays fully inside the box for every box, including single-row boxes.
Actual Behavior
The one-row "Learn" badge is ~1.1" tall inside a 0.85" container, so it protrudes above the box top and below the box bottom. The two-row "Reference" badge is fine.
Additional Context
Root cause in add_resource_box_slide (src/presentations/slides.py):
- Container height scales with rows:
container_height = Inches(0.5 * num_rows + 0.35)(slides.py:353) → 1 row = 0.85". - Badge height is fixed at the style default 1.1" (
style.py:13). - Badge is centered with
badge_y = box_top + Inches((container_height/Inches(1) - badge_h) / 2)(slides.py:444); whenbadge_h > container_heightthe offset is negative.
Suggested fix: clamp the badge to effective_badge_h = min(badge_h, container_height/Inches(1)) and center on that value. Leaves container_height untouched, so it composes with the divider/row-centering fix. Multi-row boxes are unaffected (min() returns the original badge_h).
- Dominant language
- Python
- Stars
- 10
- Forks
- 3
- Avg merge
- 24d 6h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/presentations
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
microsoft/presentations#12 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/presentations#11 ·
-
Difficulty 2/5 Half a day Newbie friendliness 82/100
-
Difficulty 5/5 Over a week Newbie friendliness 48/100
microsoft/presentations#18 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
microsoft/presentations#17 · 1 comment ·
All issues in microsoft/presentations
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100