html

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package html implements a component wrapper for Paper's HTML translator.

Index

Constants

This section is empty.

Variables

View Source
var (
	// WithUnsupportedHandler registers a callback invoked for unsupported HTML
	// tags or CSS properties.
	WithUnsupportedHandler = paperhtml.WithUnsupportedHandler
	// WithGridSize overrides the default grid size used for flex quantization.
	WithGridSize = paperhtml.WithGridSize
	// WithContentWidth sets the content width in mm for width-aware CSS features.
	WithContentWidth = paperhtml.WithContentWidth
	// WithImageBaseDir scopes local image reads to a single directory.
	WithImageBaseDir = paperhtml.WithImageBaseDir
	// WithStylesheetBaseDir scopes local stylesheet reads to a single directory.
	WithStylesheetBaseDir = paperhtml.WithStylesheetBaseDir
	// WithLimits configures resource limits for untrusted HTML.
	WithLimits = paperhtml.WithLimits
	// WithUnsafeNoLimits disables resource limits for trusted HTML.
	WithUnsafeNoLimits = paperhtml.WithUnsafeNoLimits
)

Re-exported translation options. These alias pkg/html so the component facade stays in sync with the underlying translator's signatures.

Functions

func NewAutoRow

func NewAutoRow(htmlStr string, opts ...Option) (core.Row, error)

NewAutoRow wraps an HTML component in an auto-height row.

func NewCol

func NewCol(size int, htmlStr string, opts ...Option) (core.Col, error)

NewCol wraps an HTML component in a column of the given grid size.

func NewRow

func NewRow(height float64, htmlStr string, opts ...Option) (core.Row, error)

NewRow wraps an HTML component in a fixed-height row.

Types

type HTML

type HTML struct {
	// contains filtered or unexported fields
}

HTML is a core.Component backed by rows produced from an HTML fragment.

func New

func New(htmlStr string, opts ...Option) (*HTML, error)

New converts an HTML string into a component that can be placed inside a column like any other Paper component.

func (*HTML) GetHeight

func (h *HTML) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the sum of the translated row heights inside the target cell width.

func (*HTML) GetStructure

func (h *HTML) GetStructure() *node.Node[core.Structure]

GetStructure returns the component tree node for snapshots/debugging.

func (*HTML) Render

func (h *HTML) Render(provider core.Provider, cell *entity.Cell)

Render draws each translated row sequentially inside the component cell. The pen is reset to the row origin before each child Render so cellwriter chain nodes that rely on GetXY draw at the right position, then reset to the cell origin afterwards — matching blockContainer.Render's contract.

func (*HTML) SetConfig

func (h *HTML) SetConfig(config *entity.Config)

SetConfig propagates the Paper configuration to translated rows.

type Limits

type Limits = paperhtml.Limits

Limits caps resource use while translating untrusted HTML.

type Option

type Option = paperhtml.Option

Option configures HTML component translation.

Jump to

Keyboard shortcuts

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