richtext

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 8 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package richtext implements a PDF component for paragraphs with mixed inline styling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAutoRow

func NewAutoRow(runs []props.RichRun, ps ...props.RichText) core.Row

NewAutoRow wraps a RichText in an auto-height Row.

func NewCol

func NewCol(size int, runs []props.RichRun, ps ...props.RichText) core.Col

NewCol wraps a RichText in a Col of the given grid size.

func NewRow

func NewRow(height float64, runs []props.RichRun, ps ...props.RichText) core.Row

NewRow wraps a RichText in a fixed-height Row.

Types

type RichText

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

RichText is a paragraph component that renders inline runs with mixed styles. It implements core.Component and can be placed inside Col/Row like any other component.

func New

func New(runs []props.RichRun, ps ...props.RichText) *RichText

New creates a RichText component.

func (*RichText) CloneWithRuns added in v0.2.2

func (r *RichText) CloneWithRuns(runs []props.RichRun) *RichText

CloneWithRuns preserves the paragraph styling and local-link resolver when a layout component divides its text across pages.

func (*RichText) GetHeight

func (r *RichText) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the height the component will occupy in the cell. The result is memoised by cell width so Paper's two-call pattern (addRow + Render) doesn't drift even when SetConfig is called between invocations.

func (*RichText) GetStructure

func (r *RichText) GetStructure() *node.Node[core.Structure]

GetStructure returns the component tree node for debugging/snapshot tests.

func (*RichText) Render

func (r *RichText) Render(provider core.Provider, cell *entity.Cell)

Render draws the component. If the provider implements core.RichTextProvider, it delegates to AddRichText for accurate per-run styling. Otherwise it falls back to AddText with the first run's style.

func (*RichText) Runs added in v0.2.2

func (r *RichText) Runs() []props.RichRun

Runs returns a copy of the styled text runs for layout continuations.

func (*RichText) SetConfig

func (r *RichText) SetConfig(config *entity.Config)

SetConfig propagates Paper configuration to the component.

func (*RichText) WithAnchorRegistry

func (r *RichText) WithAnchorRegistry(reg anchorResolverIface) *RichText

WithAnchorRegistry attaches an anchor registry so that runs with LocalAnchor produce precise per-run PDF link rectangles at render time.

Jump to

Keyboard shortcuts

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