--- name: marp-slide-overflow compatibility: Requires Node.js with marp-cli, mermaid-cli for pre-rendered diagrams, Puppeteer for overflow detection, and LibreOffice (soffice) for editable PPTX export. description: >- Detect and fix silent content overflow in Marp slide decks before exporting to PPTX/PDF/PNG (anything taller than the 1280x720 viewBox is clipped with no warning). Also covers pre-rendering mermaid fences to SVG, a PNG-based visual verification workflow, a Puppeteer overflow detector, dense/compact CSS density tiers, a fillRatio decision table, and selectable-text PPTX export. USE FOR: Marp overflow, slide content clipped, content cut off in PPTX, slide overflow detection, Marp scrollHeight, dense/compact class, fillRatio, marp-cli overflow, Marp backgroundColor frontmatter, Marp mermaid not rendering, mermaid-cli mmdc, pre-render mermaid SVG, mermaid missing in PDF/PPTX, verify slide fits PNG, split slide vs shrink, editable PPTX, selectable text PPTX, marp pptx-editable, SOFFICE_PATH, LibreOffice PPTX, editable PPTX notes, speaker notes dropped, pptx-editable notes missing, copy pptx notes, python-pptx notes. DO NOT USE FOR: Reveal.js, Slidev, PowerPoint authoring, generic CSS layout, font rendering bugs. --- # Marp Slide Overflow — Detect, Fix, Verify ## When to Use - A Marp deck exports cleanly to HTML preview but **content is missing in PPTX/PDF/PNG**. - Tables, code blocks, or long paragraphs look truncated in the rendered output. - You added content to a slide and aren't sure if it still fits. - You need a **CI gate** that fails the build if any slide overflows. - You want a single browser-based view that puts source markdown next to the rendered slide image so you can review the entire deck quickly. ## The Root Cause: Silent Clipping Marp wraps every slide in: ```html
``` The `
` has `overflow: hidden` applied by the Marpit theme. Anything taller than 720 px is **silently clipped**. There is no warning in the Marp CLI output, no red error in the VS Code preview, no hint in the PPTX. The bottom of your table just isn't there. This bites hardest when: - A code block, table, or markdown list grows over time and crosses the 720 px threshold. - A custom CSS theme reduces line-height or font-size in some places but not others, making overflow inconsistent. - The deck builds from a single source file into multiple sub-decks (1h / 2h / 4h pattern), so the same slide may overflow in one variant but not another. ## The Detection Strategy The **only** reliable way to detect overflow is to render the deck and measure each section's `scrollHeight` against the viewBox height. Line-count or character-count heuristics miss tables, code blocks with long lines, and CSS-driven layouts. ``` Marp source.md │ ▼ marp --html → rendered.html (one file with N
per slide) │ ▼ Headless Chromium (Puppeteer) loads rendered.html │ ▼ For each
: contentHeight = section.scrollHeight ← includes clipped overflow frameHeight = svg.viewBox.height ← the visible frame (720) overflowY = max(0, contentHeight - frameHeight) fillRatio = contentHeight / frameHeight ``` `scrollHeight` reports the **full** content height including the clipped portion, which is exactly the diagnostic we need. ## Gotcha: Marp does not render ` ```mermaid ` fences Marp CLI has **no built-in mermaid support**. A ` ```mermaid ` fenced code block is emitted into the rendered HTML/PDF/PPTX as a literal `
` block — never a diagram, and with no warning. Client-side mermaid.js plugins only work in `--html` output; they leave a static `
` in `--pdf`/`--pptx`. The reliable fix is to **pre-render every ` ```mermaid ` fence to an SVG on disk** during deck assembly (via `mermaid-cli` / `mmdc`) and replace the fence with a `![](…)` image reference, then constrain image height in CSS so the SVG fits the 720 px viewBox.

> **Full recipe** — `mmdc` pre-render script, mermaid syntax gotchas (`{}`/`()`/`[]` in labels, `
`, backticks), regression detection, and diagram-sizing CSS: [`references/mermaid-prerender.md`](references/mermaid-prerender.md). ### Gotcha — `section img { display: block }` pushes inline emoji onto their own line The diagram-sizing rule above (`section img { … display: block; … }`) is a **broad selector**: it matches *every* `` Marp emits, not just your mermaid SVGs. If the theme renders emoji as images (Twemoji — the default on many Marp themes turns `☕`, `🐢`, `🌐` into ``), `display: block` forces each emoji onto its own line, so a bullet like `… at 2 a.m. ☕` wraps the coffee cup to a new line and a one-line contact row (`🌐 site 🐙 github 🐦 x`) collapses into a vertical stack. Fix: scope a counter-rule for the emoji class, on the affected slide (`