Documentation
¶
Overview ¶
Package rtfwrite renders a cssbox tree (the shared box model produced by the HTML, DOCX, Markdown, and PDF-extraction frontends) to a Rich Text Format document. Like the Markdown and DOCX writers — and unlike the raster and PDF backends — it is a STRUCTURE writer: it walks the box tree directly, reading the semantic annotations (SemTag/HeadingLvl/Href), display kinds, and computed style, and emits headings, paragraphs, emphasis, hyperlinks, lists, block quotes, code blocks, tables, and embedded pictures as native RTF constructs. It is deliberately not layout-faithful: floats, positioning, and exact CSS geometry degrade to normal flow.
Every mapping is chosen so this repo's own RTF reader (pkg/rtf) round-trips it: block semantics ride on stylesheet names (\s styles "heading N", Quote, CodeBlock, HorizontalRule — with \outlinelevel as the heading fallback any other reader also understands), lists on \ls/\ilvl plus a literal \pntext marker, hyperlinks on HYPERLINK fields, inline code on the monospace font, tables on \trowd/\cellx rows (\trhdr header rows; spanned cells duplicated into every covered slot, the same expansion the Markdown writer performs), and pictures on \pict png/jpeg blobs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// PageWidthPt, PageHeightPt set the page size in points; default US Letter
// (612x792) when zero.
PageWidthPt, PageHeightPt float64
// MarginPt is the uniform page margin in points; default 72 (1in) when
// zero. A negative value means no margin (0).
MarginPt float64
// Loader resolves image refs (an <img> src) to bytes for embedding as
// \pict blobs. 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 RTF output.