pptxwrite

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package pptxwrite renders a cssbox tree (the shared box model produced by the HTML, DOCX, Markdown, and PDF-extraction frontends) to a PresentationML (.pptx) deck. Like the Markdown, DOCX, and RTF writers it is a STRUCTURE writer: it walks the box tree directly and emits native PowerPoint constructs. It is deliberately not layout-faithful — a document reflows into slides, it is not paginated onto them.

The slide mapping: every <h1>/<h2> starts a NEW slide with that heading as the title placeholder; the blocks that follow become the slide's body — one text box accumulating paragraphs and (nested, bullet/numbered) list items, with each table emitted as a native a:tbl graphic frame and each image as a p:pic media part. Content before the first heading yields an untitled slide. Every mapping is chosen so this repo's own PPTX reader (pkg/pptx) round-trips it: titles on the title placeholder, list kind/depth on buChar/buAutoNum + lvl, emphasis on rPr b/i, table spans on gridSpan/rowSpan + hMerge/vMerge continuation cells.

Documented degrades (logged): h3–h6 become bold body paragraphs (PPTX has one title kind per slide); blockquote/code semantics flatten to plain paragraphs (no PPTX construct); hyperlink targets drop (text kept); hr is skipped; over-tall slides overflow their frame (clipped visually, content preserved for conversion).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(ctx context.Context, root *cssbox.Box, w io.Writer, opts Options) error

Write renders the cssbox tree rooted at root to w as a complete .pptx package. root is expected to be a finalized tree (post box-generation fixups). A nil root writes a valid one-empty-slide deck.

Types

type Options

type Options struct {
	// SlideWidthPt, SlideHeightPt set the slide size in points; default 16:9
	// (960x540, PowerPoint's default) when zero.
	SlideWidthPt, SlideHeightPt float64
	// Loader resolves image refs (an <img> src) to bytes for embedding as
	// media parts. data: URIs decode without a loader; for the rest, nil means
	// images degrade to their alt text (logged).
	Loader resource.ResourceLoader
	// Logf receives degradation diagnostics (e.g. a construct the writer
	// cannot represent). nil -> no-op.
	Logf func(string, ...any)
}

Options configures PPTX output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL