Documentation
¶
Overview ¶
Package render provides a document-rendering adapter that converts Markdown and HTML content into PDF and raster-image formats.
Sub-packages:
- render/typst — Typst+pandoc pipeline (zero chromedp deps)
- render/html — goldmark Markdown→HTML pipeline
- render/chrome — chromedp Headless-Chrome PDF/image pipeline
Index ¶
- type CoverPage
- type ImageEmbedOptions
- type Option
- func WithCoverPage(cp CoverPage) Option
- func WithCustomCSS(css string) Option
- func WithDirectives(enabled bool) Option
- func WithImageEmbedding(enabled bool) Option
- func WithImageEmbeddingOptions(ie ImageEmbedOptions) Option
- func WithMermaid(enabled bool) Option
- func WithTOC(enabled bool) Option
- func WithTheme(name string) Option
- func WithTitle(t string) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CoverPage ¶
type CoverPage struct {
Title string
Subtitle string
Author string
Date string // empty -> today in YYYY-MM-DD
Logo string // path or data: URL
}
CoverPage configures the optional first-page cover. Use WithCoverPage.
type ImageEmbedOptions ¶
type ImageEmbedOptions struct {
Enabled bool
Workspace string // root dir for resolving relative/file:// paths
MaxBytes int64 // per-image cap; 0 uses a sensible default (5 MB)
AllowedHosts []string // nil -> any public host (private IPs always rejected)
Timeout time.Duration // per-image fetch timeout; 0 uses 5s default
}
ImageEmbedOptions configures inline-embedding of <img> resources into the rendered HTML as data: URLs, producing a self-contained PDF. Use WithImageEmbedding or WithImageEmbeddingOptions.
type Option ¶
type Option func(*Options)
Option configures HTML rendering. Use With* constructors for readability; mutation via direct struct access is still supported for backward-compat.
func WithCoverPage ¶
WithCoverPage sets a cover page to be rendered as the first page of the PDF, separated from the body by a page break.
func WithCustomCSS ¶
WithCustomCSS appends additional CSS after the theme's default.
func WithDirectives ¶
WithDirectives toggles directive-block parsing (:::name{...} ... :::). Default false. When enabled, the goldmark parser is extended with the directive block parser and every registered Handler participates in AST transform + HTML render.
func WithImageEmbedding ¶
WithImageEmbedding toggles inline-embedding of <img> sources as data: URLs. Defaults apply (5 MB per image, 5 s timeout, public hosts only).
func WithImageEmbeddingOptions ¶
func WithImageEmbeddingOptions(ie ImageEmbedOptions) Option
WithImageEmbeddingOptions configures inline-embedding in detail. Enabled is forced to true; use WithImageEmbedding(false) to disable.
func WithMermaid ¶
WithMermaid toggles mermaid diagram rendering. When enabled, fenced code blocks with info "mermaid" render as SVG via a CDN-loaded mermaid.js.
type Options ¶
type Options struct {
// Title is the document title. When empty, the first H1 heading in the
// markdown is used; if no H1 is found, the title falls back to "Document".
Title string
// CustomCSS is appended after the preset CSS and overrides it.
CustomCSS string
// Theme selects a registered theme CSS (default: "report").
Theme string
// TOC, when true, prepends a table of contents derived from document headings.
TOC bool
// CoverPage sets an optional first-page cover.
CoverPage *CoverPage
ImageEmbed ImageEmbedOptions
Mermaid bool
// Directives enables directive-block parsing (:::name{...} ... :::).
// Default false for zero-risk behavior; callers opt in via WithDirectives.
Directives bool
// Width is the target image width in pixels; 0 means use the theme default.
// Honored by the Typst image pipeline only.
Width int
// Height is the target image height in pixels; 0 means use the theme default.
// Honored by the Typst image pipeline only.
Height int
// PPI is the pixels-per-inch density for PNG output. 0 falls back to 144.
PPI int
}
Options holds HTML rendering configuration. Prefer the With* functional options for new code; the struct is exported for backward-compat and may gain fields over time.
Directories
¶
| Path | Synopsis |
|---|---|
|
image.go provides raster-image capture via CDP, mirroring the PDF rendering design (one-shot RenderImage + persistent Printer.CaptureImage).
|
image.go provides raster-image capture via CDP, mirroring the PDF rendering design (one-shot RenderImage + persistent Printer.CaptureImage). |
|
Package html converts markdown content to styled HTML suitable for headless-Chrome PDF printing.
|
Package html converts markdown content to styled HTML suitable for headless-Chrome PDF printing. |
|
directives
Package directives implements the ::: directive-block framework for go-kit's HTML/PDF renderer.
|
Package directives implements the ::: directive-block framework for go-kit's HTML/PDF renderer. |
|
directives/all
Package all imports every built-in directive subpackage so its init() self-registers with the directives registry.
|
Package all imports every built-in directive subpackage so its init() self-registers with the directives registry. |
|
directives/callout
Package callout implements the :::callout{type=...
|
Package callout implements the :::callout{type=... |
|
directives/grid
Package grid implements the :::grid{cols=N} directive.
|
Package grid implements the :::grid{cols=N} directive. |
|
directives/math
Package math implements the :::math directive, which renders a raw LaTeX source block inside a .vaelor-math container.
|
Package math implements the :::math directive, which renders a raw LaTeX source block inside a .vaelor-math container. |
|
directives/stats
Package stats implements the :::stats{...} directive.
|
Package stats implements the :::stats{...} directive. |
|
directives/timeline
Package timeline implements the :::timeline directive, which renders a vertical list of date/event pairs.
|
Package timeline implements the :::timeline directive, which renders a vertical list of date/event pairs. |