tablefmt

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tablefmt answers "what does the canonical aligned form of a pipe-table look like for these source lines?" Callers ask the package to format a string of markdown, to spot non-conforming tables in a parsed line list, or to rewrite the source bytes in place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLines

func FormatLines(source []byte, lines [][]byte, codeLines map[int]bool, pad int) []byte

FormatLines rewrites every table found in source with canonical formatting, preserving everything else. lines must be the result of splitting source on newlines (i.e. f.Lines from internal/lint).

func FormatString

func FormatString(s string, pad int) string

FormatString formats all markdown tables in s with the given padding and returns the result. Padding less than 0 falls back to 1 (one space of padding on each side of cell content).

Types

type Violation

type Violation struct {
	StartLine int    // 1-based line number of the table's first row
	Message   string // diagnostic message including the first differing row
}

Violation describes a single table whose source formatting differs from the canonical layout produced by this package.

func Violations

func Violations(lines [][]byte, codeLines map[int]bool, pad int) []Violation

Violations returns the formatting violations found in lines. codeLines maps 1-based line numbers known to sit inside a fenced or indented code block; those lines are skipped.

Jump to

Keyboard shortcuts

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