Resource-box badge taller than its container

Open Beginner friendly
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
tooling

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-presentations version: 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
  1. Author a resource-box slide with at least one box that has a single row.
  2. Keep the default badge_height (1.1").
  3. 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); when badge_h > container_height the 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/presentations

All issues in microsoft/presentations

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.