htmllist

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package htmllist implements HTML-style bullet and numbered list components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMarker

func FormatMarker(style StyleType, idx int) string

FormatMarker returns the formatted marker string for a given style and 0-based index.

Types

type HTMLList

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

HTMLList is a core.Component rendering bullet/numbered lists.

func New

func New(items []Item, ps ...Prop) *HTMLList

New creates an HTMLList component.

func (*HTMLList) GetHeight

func (l *HTMLList) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight returns the total height of the list (items + sub-lists).

func (*HTMLList) GetStructure

func (l *HTMLList) GetStructure() *node.Node[core.Structure]

GetStructure returns the component node for snapshots/debugging.

func (*HTMLList) Render

func (l *HTMLList) Render(provider core.Provider, cell *entity.Cell)

Render draws all list items into the PDF cell. Each item's row height is the actual wrapped height of its content (not a fixed single-line itemH) — this prevents markers from stacking when items have long text that wraps to multiple lines. The marker (text or circle) is always positioned at the top of its item's row, anchored to the first line of content.

func (*HTMLList) SetConfig

func (l *HTMLList) SetConfig(config *entity.Config)

SetConfig propagates Paper config to all item components.

type Item

type Item struct {
	Content core.Component
	SubList *HTMLList
}

Item is a single list entry.

type Prop

type Prop struct {
	Style         StyleType
	Start         int     // 1-based first marker value; 0 = default
	Reversed      bool    // ordered markers count down from Start or item count
	Indent        float64 // mm per nesting level
	MarkerPadding float64 // mm gap between marker and content
	GutterWidth   float64 // 0 = measure at render time

	// MarkerBackground is the fill color used for circle markers (DecimalCircle).
	// Default: dark navy (#1a3e72) when nil.
	MarkerBackground *props.Color
	// MarkerTextColor is the text color used for the number inside circle markers.
	// Default: white when nil.
	MarkerTextColor *props.Color
}

Prop holds list-level configuration.

type StyleType

type StyleType string

StyleType controls the marker style.

const (
	None          StyleType = "none"
	Bullet        StyleType = "bullet"
	Decimal       StyleType = "decimal"
	DecimalCircle StyleType = "decimal-circle"
	LowerAlpha    StyleType = "lower-alpha"
	UpperAlpha    StyleType = "upper-alpha"
	LowerRoman    StyleType = "lower-roman"
	UpperRoman    StyleType = "upper-roman"
)

Jump to

Keyboard shortcuts

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