table

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTablePlugin

func NewTablePlugin(opts ...option) converter.Plugin

func WithHeaderPromotion

func WithHeaderPromotion(promote bool) option

WithHeaderPromotion configures whether the first row should be treated as a header when the table has no explicit header row (e.g. <th> elements). When set to true, the first row will be converted to a header row with separator dashes. When false (default), all rows are treated as regular content.

func WithNewlineBehavior added in v2.3.2

func WithNewlineBehavior(behavior NewlineBehavior) option

WithNewlineBehavior configures how to handle newlines in table cells. When set to NewlineBehaviorSkip (default), tables with newlines in cells are skipped. When set to NewlineBehaviorPreserve, newlines are preserved in cells.

Markdown tables don't support multiline content by default, so this provides a workaround to still convert tables with newlines.

func WithPresentationTables

func WithPresentationTables(convert bool) option

WithPresentationTables configures whether tables marked with role="presentation" should be converted to markdown. When set to true, presentation tables will be converted like regular tables. When false (default), these tables are skipped since they typically represent layout rather than semantic content.

func WithSkipEmptyRows

func WithSkipEmptyRows(skip bool) option

WithSkipEmptyRows configures the table plugin to omit empty rows from the output. An empty row is defined as a row where all cells contain no content or only whitespace. When set to true, empty rows will be omitted from the output. When false (default), all rows are preserved.

func WithSpanCellBehavior

func WithSpanCellBehavior(behavior SpanCellBehavior) option

WithSpanCellBehavior configures how cells affected by colspan/rowspan attributes should be rendered. When a cell spans multiple columns or rows, the affected cells can either be empty or contain the same content as the original cell.

Types

type NewlineBehavior added in v2.3.2

type NewlineBehavior string
const (
	// NewlineBehaviorSkip skips tables with newlines in cells (default).
	NewlineBehaviorSkip NewlineBehavior = "skip"
	// NewlineBehaviorPreserve preserves newlines in cells.
	NewlineBehaviorPreserve NewlineBehavior = "preserve"
)

type SpanCellBehavior

type SpanCellBehavior string
const (
	// SpanBehaviorEmpty renders an empty cell.
	SpanBehaviorEmpty SpanCellBehavior = "empty"
	// SpanBehaviorMirror renders the same content as the original cell.
	SpanBehaviorMirror SpanCellBehavior = "mirror"
)