Skip to content

✨ feat: add -format pptx that places each rendered slide on a PowerPoint slide - #88

Merged
135yshr merged 2 commits into
feat/79-fit-mermaidfrom
feat/80-pptx
Sep 21, 2026
Merged

135yshr merged 2 commits into
feat/79-fit-mermaidfrom
feat/80-pptx

Conversation

@135yshr

@135yshr 135yshr commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Stacked on #87 (#79) → #86 → #85 → #84 → #83 → #82 → #81. The diff shown here is #80 only. CI runs only for pull requests into main; until this is retargeted it is verified locally (below).

Summary

The deliverable of #72: -format pptx (or -o *.pptx) writes a PowerPoint deck.

md2pdf -format pptx deck.md      # → deck.pptx

Each slide is rendered by the Chromium that prints the PDF and placed on its own slide as a picture (image-based, approach A in #72), so the PPTX looks exactly like the slide-mode PDF. Presenter notes (#77) go to the notes pages; the front-matter title becomes the presentation title. A pptx conversion is always a deck — no marp: true needed.

Closes #80
Closes #72

Changes

  • slidecapture.go: renderSlidePNGs — viewport = slide size at device scale 2, print media, fonts awaited, overflow measured (warnings as for PDF), each section.slide captured with a clipped Page.captureScreenshot (captureBeyondViewport).
  • pptx.go: writePPTX, hand-written OOXML via archive/zip, no new dependency. Minimal package: master, blank layout, theme, one full-bleed p:pic per slide; notes master (with its own theme) and notes slides only when some slide has notes.
  • pdf.go: browser start-up and the fonts wait extracted into startBrowser / awaitFonts, shared by PDF and PPTX.
  • converter.go: FormatPPTX, writeDeckPPTX; pptx forces slide mode (so explicit -page-size / -margin-* are rejected as for any deck).
  • CLI: .pptx inference, -format pptx, -slides accepted with pptx, stdin needs -o (existing rule), help text. -doctor: pptx needs a Chromium.
  • New integration test TestConvert_IntegrationDeck: a deck with a 13-node Mermaid flowchart under a heading, converted with the real mmdc to PDF and PPTX, must not overflow. This also covers what feat: fit Mermaid diagrams within the slide #79 could only test with a stand-in SVG.

Tests

  • pptx_test.go (no browser): slide count and sldSz 12192000×6858000 / 9144000×6858000 EMU, full-bleed picture, notes only where there are notes and escaped, no notes parts at all without notes, title escaped in core.xml, empty deck rejected, and TestWritePPTX_PackageIsConsistent — every XML part well-formed, every part has a content type, every override names a real part, every relationship target exists.
  • pptxout_test.go (real Chrome): 3 slides → 3 PNGs of 2560×1440 that differ from each other, notes on slide 2, title; 4:3 → 1920×1440; plain file is still a deck; overflow warning; paper flags rejected.
  • CLI and -doctor tables extended.
  • Locally: go vet ./..., go test ./..., golangci-lint run ./... (0 issues).
  • Opened with python-pptx 1.0.2 (in a scratch venv): 3 slides, 12192000×6858000, one 2560×1440 picture per slide, notes text and title read back correctly.
  • Compared with the PDF: each captured slide vs the PDF page rasterized at 192 dpi — 0.27% / 0.51% / 0.38% of pixels differ by more than 32/255, i.e. antialiasing between poppler and Skia; layout is identical.

Not verified

  • Opening in PowerPoint, Keynote, Google Slides or LibreOffice Impress. None is available here (the issue asked for a manual LibreOffice check recorded in the PR). The package-consistency test and python-pptx are the stand-ins. Please open one generated file before merging.
  • The mmdc integration test did not run locally (no mmdc); it runs in CI once this is retargeted to main.
  • The issue's "PPTX image matches PDF page" criterion is checked by hand (numbers above), not by an automated test: comparing needs a PDF rasterizer the test suite does not have.

Review focus

  • The OOXML is hand-written. I kept it to the parts every consumer requires and wrote the integrity test against the package rules rather than against a specific reader, but real-application compatibility is exactly what I could not check.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 90bb1134-dadb-40a7-bfc2-e2cdd4b507f6

📥 Commits

Reviewing files that changed from the base of the PR and between e5b2c7d and b91d731.

📒 Files selected for processing (14)
  • CLAUDE.md
  • README.md
  • internal/cli/flags.go
  • internal/cli/flags_test.go
  • internal/cli/usage.go
  • internal/converter/converter.go
  • internal/converter/converter_integration_test.go
  • internal/converter/diagnose.go
  • internal/converter/diagnose_test.go
  • internal/converter/pdf.go
  • internal/converter/pptx.go
  • internal/converter/pptx_test.go
  • internal/converter/pptxout_test.go
  • internal/converter/slidecapture.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T09:26:50.863784Z 21424d2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21424d20d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/converter/slidecapture.go Outdated
if err != nil {
return fmt.Errorf("capture slide %d: %w", i+1, err)
}
images = append(images, img)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stream slide images instead of buffering the whole deck

For large or photo-heavy decks, every full-resolution screenshot is retained in images until capture completes, after which writePPTX also constructs the entire ZIP in a bytes.Buffer before writing it. This requires memory for all PNGs plus approximately the complete PPTX concurrently, so otherwise valid decks can exhaust memory; write captures through temporary files or directly into a streaming ZIP so each image can be released before processing the next slide.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed on this PR: renderSlidePNGs writes each capture to the working directory as soon as it is taken and returns paths; writePPTX streams the zip into a temporary file beside the destination, copying one image at a time, and renames it into place only when complete. New tests: the embedded image is byte-identical to the captured file, and a missing image fails without leaving any file behind. Re-checked a generated deck with python-pptx.

@135yshr
135yshr added this pull request to stack #89 September 21, 2026 09:29
@135yshr 135yshr self-assigned this Sep 21, 2026
135yshr and others added 2 commits September 21, 2026 18:35
…int slide

-format pptx (or -o *.pptx) renders the document as a deck, captures each
slide with headless Chromium at 2x, and writes a PowerPoint file by hand with
archive/zip: one full-bleed picture per slide, presenter notes on the notes
pages, the front-matter title as the presentation title.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… them

Every capture was held in memory until the end, and the whole package was
built in a bytes.Buffer before being written. Captures now go to the working
directory as they are taken and the zip is streamed into a temporary file
renamed into place when complete, so a failure leaves no partial .pptx.
Codex review on #88.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@135yshr
135yshr merged commit ffb2702 into main Sep 21, 2026
6 checks passed
@135yshr
135yshr deleted the feat/80-pptx branch September 21, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add -format pptx that places each rendered slide on a PowerPoint slide epic: PowerPoint (PPTX) output through a Marp-compatible slide mode

1 participant