Documentation
¶
Overview ¶
Package tableformat implements MDS025, the single table rule. It owns table parsing, the three structural checks (MD055 table-pipe-style, MD056 table-column-count, MD058 blanks-around-tables), and the prettier-style alignment pass that gives the rule its name.
Index ¶
- Constants
- type Rule
- func (r *Rule) ApplySettings(s map[string]any) error
- func (r *Rule) Category() string
- func (r *Rule) Check(f *lint.File) []lint.Diagnostic
- func (r *Rule) DefaultSettings() map[string]any
- func (r *Rule) Fix(f *lint.File) []byte
- func (r *Rule) GetPad() int
- func (r *Rule) GetSeparatorStyle() tablefmt.SeparatorStyle
- func (r *Rule) ID() string
- func (r *Rule) Name() string
Constants ¶
const ( // StyleConsistent infers the required edge-pipe shape from the // table's header row and holds every other row to it. StyleConsistent = "consistent" // StyleLeadingAndTrailing requires a leading and a trailing pipe // on every row. StyleLeadingAndTrailing = "leading_and_trailing" // StyleNoLeadingOrTrailing forbids leading and trailing pipes on // every row. StyleNoLeadingOrTrailing = "no_leading_or_trailing" )
Pipe-style values for the `style` setting (MD055).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rule ¶
type Rule struct {
Pad int // spaces on each side of cell content
SeparatorStyle tablefmt.SeparatorStyle
Style string // edge-pipe style: one of the Style* constants
}
Rule gates table well-formedness: edge-pipe style (MD055), column count vs the header (MD056), surrounding blank lines (MD058), and the column-alignment / padding pass that gives the rule its name.
func (*Rule) ApplySettings ¶
ApplySettings implements rule.Configurable.
func (*Rule) Check ¶
func (r *Rule) Check(f *lint.File) []lint.Diagnostic
Check implements rule.Rule. It emits both the structural diagnostics (MD055/056/058) and the alignment diagnostics produced by the prettier-style format pass.
func (*Rule) DefaultSettings ¶
DefaultSettings implements rule.Configurable.
func (*Rule) Fix ¶
Fix implements rule.FixableRule. The structure pass runs first (edge normalization for MD055, blank-line insertion for MD058) so the alignment pass then sees the structurally-normalized bytes and canonicalizes the remaining bordered tables. GeneratedRanges are recomputed on the reparsed buffer: a blank line inserted before a downstream generated section shifts that section's line numbers, so copying the pre-fix ranges would point the alignment pass's skip set at the wrong lines. tablefmt is CRLF-aware, so no post-pass normalisation is needed for mixed-ending output.
func (*Rule) GetSeparatorStyle ¶ added in v0.23.0
func (r *Rule) GetSeparatorStyle() tablefmt.SeparatorStyle
GetSeparatorStyle returns the active separator style.