package renderer
import "github.com/olekukonko/tablewriter/renderer"
Index ¶
- type Blueprint
- func NewBlueprint(configs ...tw.Rendition) *Blueprint
- func (f *Blueprint) Close() error
- func (f *Blueprint) Config() tw.Rendition
- func (f *Blueprint) Footer(footers [][]string, ctx tw.Formatting)
- func (f *Blueprint) Header(headers [][]string, ctx tw.Formatting)
- func (f *Blueprint) Line(ctx tw.Formatting)
- func (f *Blueprint) Logger(logger *ll.Logger)
- func (f *Blueprint) Rendition(config tw.Rendition)
- func (f *Blueprint) Row(row []string, ctx tw.Formatting)
- func (f *Blueprint) Start(w io.Writer) error
- type Colorized
- func NewColorized(configs ...ColorizedConfig) *Colorized
- func (c *Colorized) Close() error
- func (c *Colorized) Config() tw.Rendition
- func (c *Colorized) Debug() []string
- func (c *Colorized) Footer(footers [][]string, ctx tw.Formatting)
- func (c *Colorized) Header(headers [][]string, ctx tw.Formatting)
- func (c *Colorized) Line(ctx tw.Formatting)
- func (c *Colorized) Logger(logger *ll.Logger)
- func (c *Colorized) Rendition(newRendition tw.Rendition)
- func (c *Colorized) Reset()
- func (c *Colorized) Row(row []string, ctx tw.Formatting)
- func (c *Colorized) Start(w io.Writer) error
- type ColorizedConfig
- type Colors
- type HTML
- func NewHTML(configs ...HTMLConfig) *HTML
- func (h *HTML) Close() error
- func (h *HTML) Config() tw.Rendition
- func (h *HTML) Debug() []string
- func (h *HTML) Footer(footers [][]string, ctx tw.Formatting)
- func (h *HTML) Header(headers [][]string, ctx tw.Formatting)
- func (h *HTML) Line(ctx tw.Formatting)
- func (h *HTML) Logger(logger *ll.Logger)
- func (h *HTML) Reset()
- func (h *HTML) Row(row []string, ctx tw.Formatting)
- func (h *HTML) Start(w io.Writer) error
- type HTMLConfig
- type Junction
- func NewJunction(ctx JunctionContext) *Junction
- func (jr *Junction) GetSegment() string
- func (jr *Junction) RenderJunction(leftColIdx, rightColIdx int) string
- func (jr *Junction) RenderLeft() string
- func (jr *Junction) RenderRight(lastColIdx int) string
- type JunctionContext
- type Markdown
- func NewMarkdown(configs ...tw.Rendition) *Markdown
- func (m *Markdown) Close() error
- func (m *Markdown) Config() tw.Rendition
- func (m *Markdown) Footer(footers [][]string, ctx tw.Formatting)
- func (m *Markdown) Header(headers [][]string, ctx tw.Formatting)
- func (m *Markdown) Line(ctx tw.Formatting)
- func (m *Markdown) Logger(logger *ll.Logger)
- func (m *Markdown) Reset()
- func (m *Markdown) Row(row []string, ctx tw.Formatting)
- func (m *Markdown) Start(w io.Writer) error
- type Ocean
- func NewOcean(oceanConfig ...OceanConfig) *Ocean
- func (o *Ocean) Close() error
- func (o *Ocean) Config() tw.Rendition
- func (o *Ocean) Footer(footers [][]string, ctx tw.Formatting)
- func (o *Ocean) Header(headers [][]string, ctx tw.Formatting)
- func (o *Ocean) Line(ctx tw.Formatting)
- func (o *Ocean) Logger(logger *ll.Logger)
- func (o *Ocean) Rendition(config tw.Rendition)
- func (o *Ocean) Row(row []string, ctx tw.Formatting)
- func (o *Ocean) Start(w io.Writer) error
- type OceanConfig
- type SVG
- func NewSVG(configs ...SVGConfig) *SVG
- func (s *SVG) Close() error
- func (s *SVG) Config() tw.Rendition
- func (s *SVG) Debug() []string
- func (s *SVG) Footer(footers [][]string, ctx tw.Formatting)
- func (s *SVG) Header(headers [][]string, ctx tw.Formatting)
- func (s *SVG) Line(ctx tw.Formatting)
- func (s *SVG) Logger(logger *ll.Logger)
- func (s *SVG) Reset()
- func (s *SVG) Row(rowLine []string, ctx tw.Formatting)
- func (s *SVG) Start(w io.Writer) error
- type SVGConfig
- type Tint
Types ¶
type Blueprint ¶
type Blueprint struct {
// contains filtered or unexported fields
}
Blueprint implements a primary table rendering engine with customizable borders and alignments.
func NewBlueprint ¶
NewBlueprint creates a new Blueprint instance with optional custom configurations.
func (*Blueprint) Close ¶
Close performs cleanup (no-op in this implementation).
func (*Blueprint) Config ¶
Config returns the renderer's current configuration.
func (*Blueprint) Footer ¶
func (f *Blueprint) Footer(footers [][]string, ctx tw.Formatting)
Footer renders the table footer section with configured formatting.
func (*Blueprint) Header ¶
func (f *Blueprint) Header(headers [][]string, ctx tw.Formatting)
Header renders the table header section with configured formatting.
func (*Blueprint) Line ¶
func (f *Blueprint) Line(ctx tw.Formatting)
Line renders a full horizontal row line with junctions and segments.
func (*Blueprint) Logger ¶
Logger sets the logger for the Blueprint instance.
func (*Blueprint) Rendition ¶
func (*Blueprint) Row ¶
func (f *Blueprint) Row(row []string, ctx tw.Formatting)
Row renders a table data row with configured formatting.
func (*Blueprint) Start ¶
Start initializes the rendering process (no-op in this implementation).
type Colorized ¶
type Colorized struct {
// contains filtered or unexported fields
}
Colorized renders colored ASCII tables with customizable borders, colors, and alignments.
func NewColorized ¶
func NewColorized(configs ...ColorizedConfig) *Colorized
NewColorized creates a Colorized renderer with the specified configuration, falling back to defaults if none provided. Only the first config is used if multiple are passed.
func (*Colorized) Close ¶
Close performs cleanup (no-op in this implementation).
func (*Colorized) Config ¶
Config returns the renderer's configuration as a Rendition.
func (*Colorized) Debug ¶
Debug returns the accumulated debug trace messages.
func (*Colorized) Footer ¶
func (c *Colorized) Footer(footers [][]string, ctx tw.Formatting)
Footer renders the table footer with configured colors and formatting.
func (*Colorized) Header ¶
func (c *Colorized) Header(headers [][]string, ctx tw.Formatting)
Header renders the table header with configured colors and formatting.
func (*Colorized) Line ¶
func (c *Colorized) Line(ctx tw.Formatting)
Line renders a horizontal row line with colored junctions and segments, skipping zero-width columns.
func (*Colorized) Logger ¶
Logger sets the logger for the Colorized instance.
func (*Colorized) Rendition ¶
Rendition updates the parts of ColorizedConfig that correspond to tw.Rendition by merging the provided newRendition. Color-specific Tints are not modified.
func (*Colorized) Reset ¶
func (c *Colorized) Reset()
Reset clears the renderer's internal state, including debug traces.
func (*Colorized) Row ¶
func (c *Colorized) Row(row []string, ctx tw.Formatting)
Row renders a table data row with configured colors and formatting.
func (*Colorized) Start ¶
Start initializes the rendering process (no-op in this implementation).
type ColorizedConfig ¶
type ColorizedConfig struct { Borders tw.Border // Border visibility settings Settings tw.Settings // Rendering behavior settings (e.g., separators, whitespace) Header Tint // Colors for header cells Column Tint // Colors for row cells Tint // Colors for footer cells Border Tint // Colors for borders and lines Separator Tint // Colors for column separators Symbols tw.Symbols // Symbols for table drawing (e.g., corners, lines) }
ColorizedConfig holds configuration for the Colorized table renderer.
type Colors ¶
Colors is a slice of color attributes for use with fatih/color, such as color.FgWhite or color.Bold.
type HTML ¶
type HTML struct {
// contains filtered or unexported fields
}
HTML renders tables in HTML format with customizable classes and content handling.
func NewHTML ¶
func NewHTML(configs ...HTMLConfig) *HTML
NewHTML initializes an HTML renderer with the given w, debug setting, and optional configuration. It panics if the w is nil and applies defaults for unset config fields. Update: see https://github.com/olekukonko/tablewriter/issues/258
func (*HTML) Close ¶
Close ensures all open HTML tags (<table>, <tbody>, <tfoot>) are properly closed.
func (*HTML) Config ¶
Config returns a Rendition representation of the current configuration.
func (*HTML) Debug ¶
Debug returns the accumulated debug trace messages.
func (*HTML) Footer ¶
func (h *HTML) Footer(footers [][]string, ctx tw.Formatting)
Footer renders the <tfoot> section with footer rows, supporting horizontal merges.
func (*HTML) Header ¶
func (h *HTML) Header(headers [][]string, ctx tw.Formatting)
Header renders the <thead> section with header rows, supporting horizontal merges.
func (*HTML) Line ¶
func (h *HTML) Line(ctx tw.Formatting)
Line is a no-op for HTML rendering, as structural lines are handled by tags.
func (*HTML) Logger ¶
func (*HTML) Reset ¶
func (h *HTML) Reset()
Reset clears the renderer's internal state, including debug traces and merge tracking.
func (*HTML) Row ¶
func (h *HTML) Row(row []string, ctx tw.Formatting)
Row renders a <tr> element within <tbody>, supporting horizontal and vertical merges.
func (*HTML) Start ¶
Start begins the HTML table rendering by opening the <table> tag.
type HTMLConfig ¶
type HTMLConfig struct { EscapeContent bool // Whether to escape cell content AddLinesTag bool // Whether to wrap multiline content in <lines> tags TableClass string // CSS class for <table> HeaderClass string // CSS class for <thead> BodyClass string // CSS class for <tbody> string // CSS class for <tfoot> RowClass string // CSS class for <tr> in body HeaderRowClass string // CSS class for <tr> in header string // CSS class for <tr> in footer }
HTMLConfig defines settings for the HTML table renderer.
type Junction ¶
type Junction struct {
// contains filtered or unexported fields
}
Junction handles rendering of table junction points (corners, intersections) with color support.
func NewJunction ¶
func NewJunction(ctx JunctionContext) *Junction
NewJunction initializes a Junction with the given symbols, context, and tints. If debug is nil, a no-op debug function is used.
func (*Junction) GetSegment ¶
GetSegment determines whether to render a colored horizontal line or an empty space based on merge states.
func (*Junction) RenderJunction ¶
RenderJunction selects and colors the junction symbol between two adjacent columns based on merge states and table position.
func (*Junction) RenderLeft ¶
RenderLeft selects and colors the leftmost junction symbol for the current row line based on position and merges.
func (*Junction) RenderRight ¶
RenderRight selects and colors the rightmost junction symbol for the row line based on position, merges, and last column index.
type JunctionContext ¶
type JunctionContext struct { Symbols tw.Symbols Ctx tw.Formatting ColIdx int Logger *ll.Logger BorderTint Tint SeparatorTint Tint }
type Markdown ¶
type Markdown struct {
// contains filtered or unexported fields
}
Markdown renders tables in Markdown format with customizable settings.
func NewMarkdown ¶
NewMarkdown initializes a Markdown renderer with defaults tailored for Markdown (e.g., pipes, header separator). Only the first config is used if multiple are provided.
func (*Markdown) Close ¶
func (*Markdown) Config ¶
Config returns the renderer's current configuration.
func (*Markdown) Footer ¶
func (m *Markdown) Footer(footers [][]string, ctx tw.Formatting)
Footer renders the Markdown table footer.
func (*Markdown) Header ¶
func (m *Markdown) Header(headers [][]string, ctx tw.Formatting)
Header renders the Markdown table header and its separator line.
func (*Markdown) Line ¶
func (m *Markdown) Line(ctx tw.Formatting)
Line is a no-op for Markdown, as only the header separator is rendered (handled by Header).
func (*Markdown) Logger ¶
func (*Markdown) Reset ¶
func (m *Markdown) Reset()
Reset clears the renderer's internal state, including debug traces.
func (*Markdown) Row ¶
func (m *Markdown) Row(row []string, ctx tw.Formatting)
Row renders a Markdown table data row.
func (*Markdown) Start ¶
type Ocean ¶
type Ocean struct {
// contains filtered or unexported fields
}
Ocean is a streaming table renderer that writes ASCII tables.
func NewOcean ¶
func NewOcean(oceanConfig ...OceanConfig) *Ocean
func (*Ocean) Close ¶
func (*Ocean) Config ¶
func (*Ocean) Footer ¶
func (o *Ocean) Footer(footers [][]string, ctx tw.Formatting)
func (*Ocean) Header ¶
func (o *Ocean) Header(headers [][]string, ctx tw.Formatting)
func (*Ocean) Line ¶
func (o *Ocean) Line(ctx tw.Formatting)
func (*Ocean) Logger ¶
func (*Ocean) Rendition ¶
func (*Ocean) Row ¶
func (o *Ocean) Row(row []string, ctx tw.Formatting)
func (*Ocean) Start ¶
type OceanConfig ¶
type OceanConfig struct { }
OceanConfig defines configuration specific to the Ocean renderer.
type SVG ¶
type SVG struct {
// contains filtered or unexported fields
}
SVG implements tw.Renderer for SVG output. Manages SVG element generation and merge tracking.
func NewSVG ¶
NewSVG creates a new SVG renderer with configuration. Parameter configs provides optional SVGConfig; defaults used if empty. Returns a configured SVG instance.
func (*SVG) Close ¶
Close finalizes SVG rendering and writes output. Parameter w is the output w. Returns an error if writing fails.
func (*SVG) Config ¶
Config returns the renderer's configuration. No parameters are required. Returns a Rendition with border and debug settings.
func (*SVG) Debug ¶
Debug returns the renderer's debug trace. No parameters are required. Returns a slice of debug messages.
func (*SVG) Footer ¶
func (s *SVG) Footer(footers [][]string, ctx tw.Formatting)
Footer buffers footer lines for SVG rendering. Parameters include w (w), footers (lines), and ctx (formatting). No return value; stores data for later rendering.
func (*SVG) Header ¶
func (s *SVG) Header(headers [][]string, ctx tw.Formatting)
Header buffers header lines for SVG rendering. Parameters include w (w), headers (lines), and ctx (formatting). No return value; stores data for later rendering.
func (*SVG) Line ¶
func (s *SVG) Line(ctx tw.Formatting)
Line handles border rendering (ignored in SVG renderer). Parameters include w (w) and ctx (formatting). No return value; SVG borders are drawn in Close.
func (*SVG) Logger ¶
func (*SVG) Reset ¶
func (s *SVG) Reset()
Reset clears the renderer's internal state. No parameters are required. No return value; prepares for new rendering.
func (*SVG) Row ¶
func (s *SVG) Row(rowLine []string, ctx tw.Formatting)
Row buffers a row line for SVG rendering. Parameters include w (w), rowLine (cells), and ctx (formatting). No return value; stores data for later rendering.
func (*SVG) Start ¶
Start initializes SVG rendering. Parameter w is the output w. Returns nil; prepares internal state.
type SVGConfig ¶
type SVGConfig struct { FontFamily string // e.g., "Arial, sans-serif" FontSize float64 // Base font size in SVG units LineHeightFactor float64 // Factor for line height (e.g., 1.2) Padding float64 // Padding inside cells StrokeWidth float64 // Line width for borders StrokeColor string // Color for strokes (e.g., "black") HeaderBG string // Background color for header RowBG string // Background color for rows RowAltBG string // Alternating row background color string // Background color for footer HeaderColor string // Text color for header RowColor string // Text color for rows string // Text color for footer ApproxCharWidthFactor float64 // Char width relative to FontSize MinColWidth float64 // Minimum column width RenderTWConfigOverrides bool // Override SVG alignments with tablewriter Debug bool // Enable debug logging ScaleFactor float64 // Scaling factor for SVG }
SVGConfig holds configuration for the SVG renderer. Fields include font, colors, padding, and merge rendering options. Used to customize SVG output appearance and behavior.
type Tint ¶
type Tint struct { FG Colors // Foreground color attributes BG Colors // Background color attributes Columns []Tint // Per-column color settings }
Tint defines foreground and background color settings for table elements, with optional per-column overrides.
func (Tint) Apply ¶
Apply applies the Tint's foreground and background colors to the given text, returning the text unchanged if no colors are set.
Source Files ¶
blueprint.go colorized.go fn.go html.go junction.go markdown.go ocean.go svg.go
- Version
- v1.0.7 (latest)
- Published
- May 27, 2025
- Platform
- js/wasm
- Imports
- 9 packages
- Last checked
- 1 week ago –
Tools for package owners.