formatter

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateAlignmentColumn

func CalculateAlignmentColumn(postings []ast.Posting) int

func CalculateGlobalAlignmentColumn

func CalculateGlobalAlignmentColumn(transactions []ast.Transaction) int

func CalculateGlobalAlignmentColumnWithIndent added in v0.2.8

func CalculateGlobalAlignmentColumnWithIndent(transactions []ast.Transaction, indentSize int) int

CalculateGlobalAlignmentColumnWithIndent returns the column at which amounts should be aligned, using the given indentSize instead of the default indent.

func FormatDocument

func FormatDocument(journal *ast.Journal, content string) []protocol.TextEdit

func FormatDocumentWithFormats

func FormatDocumentWithFormats(journal *ast.Journal, content string, commodityFormats map[string]CommodityFormat) []protocol.TextEdit

func FormatDocumentWithOptions

func FormatDocumentWithOptions(journal *ast.Journal, content string, commodityFormats map[string]CommodityFormat, opts Options) []protocol.TextEdit

func FormatNumber

func FormatNumber(qty decimal.Decimal, format NumberFormat) string

func FormatPosting

func FormatPosting(posting *ast.Posting, alignCol int) string

func FormatPostingWithAlignment

func FormatPostingWithAlignment(posting *ast.Posting, alignment AlignmentInfo, commodityFormats map[string]CommodityFormat) string

Types

type AlignmentInfo

type AlignmentInfo struct {
	AccountCol          int
	BalanceAssertionCol int
}

func CalculateAlignment

func CalculateAlignment(postings []ast.Posting, commodityFormats map[string]CommodityFormat) AlignmentInfo

CalculateAlignment calculates alignment for a single transaction's postings. For consistent file-wide alignment, use CalculateAlignmentWithGlobal with a pre-calculated global column from CalculateGlobalAlignmentColumn.

func CalculateAlignmentWithGlobal

func CalculateAlignmentWithGlobal(postings []ast.Posting, commodityFormats map[string]CommodityFormat, accountCol int) AlignmentInfo

CalculateAlignmentWithGlobal calculates alignment using a provided account column. Use this with CalculateGlobalAlignmentColumn for file-wide consistent alignment.

type CommodityFormat added in v0.2.8

type CommodityFormat struct {
	NumberFormat
	Position     ast.CommodityPosition
	SpaceBetween bool
}

func ParseCommodityFormat added in v0.2.8

func ParseCommodityFormat(formatStr string, symbol string) CommodityFormat

type NumberFormat

type NumberFormat struct {
	DecimalMark   rune
	ThousandsSep  string
	DecimalPlaces int
	HasDecimal    bool
}

func ParseNumberFormat

func ParseNumberFormat(formatStr string) NumberFormat

type Options

type Options struct {
	IndentSize         int
	AlignAmounts       bool
	MinAlignmentColumn int
}

func DefaultOptions

func DefaultOptions() Options

Jump to

Keyboard shortcuts

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