Resource-box badge label overflow or mid-word wrap

Open Beginner friendly
#11 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
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
design

Research direction

Start in src/presentations/slides.py at add_resource_box_slide, especially the badge text-frame code around lines 443 and 488-498. Run the provided uv MRE and inspect the generated .pptx with the default badge settings. Done means long labels fit without mid-word wrapping while short labels remain unchanged, with the resource-box geometry unaffected.

Written by the indexing model from the issue text.

Description

Summary

On a resource-box slide, badge labels longer than ~6 characters wrap awkwardly inside the narrow fixed-width badge — e.g. "Presentations" breaks mid-word as "Presentat ions" and "Build and Govern" stacks onto three cramped lines.

Impact

High — any resource box with a label longer than ~6 characters is hard to read. Short labels are unaffected.

Environment
  • ms-presentations version: 0.1.6
  • Python version: 3.10+
  • OS / version: reproduces on all (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 a box label longer than ~6 characters.
  2. Keep the default badge_width (0.9") and badge_font_size (11).
  3. Render 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 label overflow / mid-word wrap.

Run with:  uv run mse.py   (no venv, no Azure, no network)

Long badge labels wrap mid-word inside the fixed 0.9" badge: "Presentations"
renders as "Presentat ions" and "Build and Govern" stacks onto three cramped
lines, while the short "Learn" label is fine. Open the rendered deck and compare
the three badges — the deck is the only output.
"""
import os
import tempfile

from presentations.cli import main

SPEC = """\
---
title: Repro - Badge label overflow
output: Badge_Label_Overflow.pptx
style:
  badge_width: 0.9
  badge_font_size: 11
---

## [resource-box] Getting started

**Subtitle**: Resources

**Box**: Learn
- Microsoft AI | https://learn.microsoft.com/ai/

**Box**: Build and Govern
- Azure AI Services | https://learn.microsoft.com/azure/ai-services/

**Box**: Presentations
- Samples | https://github.com/microsoft/presentations/samples
"""

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

Long labels shrink (or otherwise fit) the badge without breaking words mid-character.

Actual Behavior

"Presentations" wraps to "Presentat ions"; "Build and Govern" stacks onto three cramped lines; "Learn" renders cleanly — showing the problem is label length, not the box.

Additional Context

Root cause in add_resource_box_slide (src/presentations/slides.py:443, 488-498): the badge is a fixed 0.9"-wide rounded rectangle with word_wrap = True at 11 pt and no auto-fit, and python-pptx does not shrink text to fit. PowerPoint hard-wraps, including mid-word when a single word exceeds the box width.

Suggested fix: set text_frame.auto_size = MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE, paired with a deterministic font step-down for long labels (so the fit is correct even in renderers that don't recompute normAutofit). This touches only the badge text frame/font — no geometry — so it's independent of the other resource-box fixes.

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.