Documentation
¶
Overview ¶
Package cssfmt provides CSS formatting, minification, and validation.
Package cssfmt provides CSS formatting, minification, validation, and parsing. It supports configurable indentation, property sorting, rule sorting, and comment removal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveComments ¶
RemoveComments removes CSS comments from input.
Types ¶
type Declaration ¶
Declaration represents a CSS property: value pair.
func ParseDeclarations ¶
func ParseDeclarations(input string) []Declaration
ParseDeclarations parses CSS declarations from a string.
type Option ¶
type Option func(*Options)
Option is a functional option for Format.
func WithSortProps ¶
func WithSortProps() Option
WithSortProps enables alphabetical property sorting.
func WithSortRules ¶
func WithSortRules() Option
WithSortRules enables alphabetical selector sorting.
type Options ¶
type Options struct {
Indent string // Indentation (default: " ")
SortProps bool // Sort properties alphabetically
SortRules bool // Sort selectors alphabetically
}
Options configures the CSS formatter.
type Rule ¶
type Rule struct {
Selector string
Declarations []Declaration
IsAtRule bool
AtRuleBody string
}
Rule represents a CSS rule (selector + declarations).
type ValidateResult ¶
type ValidateResult struct {
Valid bool `json:"valid"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
ValidateResult represents CSS validation output.
func Validate ¶
func Validate(input string) ValidateResult
Validate performs basic CSS syntax validation.