config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config provides configuration management for the markdown formatter.

Index

Constants

View Source
const (
	// DefaultLineWidth defines the default maximum line width
	DefaultLineWidth = 80
	// DefaultMaxBlankLines defines the default maximum consecutive blank lines
	DefaultMaxBlankLines = 2
	// ConfigFilePermissions defines the file permissions for config files
	ConfigFilePermissions = 0o600
)

Variables

This section is empty.

Functions

func FindConfigFile

func FindConfigFile(startDir string) (string, error)

FindConfigFile searches for configuration files in common locations

Types

type CodeConfig

type CodeConfig struct {
	// FenceStyle defines the fence style: "“`" or "~~~"
	FenceStyle string `yaml:"fence_style" json:"fence_style"`
	// LanguageDetection enables automatic language detection
	LanguageDetection bool `yaml:"language_detection" json:"language_detection"`
}

CodeConfig contains code block formatting options

type Config

type Config struct {
	// LineWidth is the maximum line width for text reflow
	LineWidth int `yaml:"line_width" json:"line_width"`

	// Heading configuration
	Heading HeadingConfig `yaml:"heading" json:"heading"`

	// List configuration
	List ListConfig `yaml:"list" json:"list"`

	// Code block configuration
	Code CodeConfig `yaml:"code" json:"code"`

	// Whitespace configuration
	Whitespace WhitespaceConfig `yaml:"whitespace" json:"whitespace"`

	// File processing configuration
	Files FilesConfig `yaml:"files" json:"files"`
}

Config represents the configuration for mdfmt

func Default

func Default() *Config

Default returns the default configuration

func (*Config) IsMarkdownFile

func (c *Config) IsMarkdownFile(filename string) bool

IsMarkdownFile checks if a file is a markdown file based on extension

func (*Config) LoadFromFile

func (c *Config) LoadFromFile(filename string) error

LoadFromFile loads configuration from a file.

func (*Config) SaveToFile

func (c *Config) SaveToFile(filename string) error

SaveToFile saves configuration to a file.

func (*Config) ShouldIgnore

func (c *Config) ShouldIgnore(path string) bool

ShouldIgnore checks if a file should be ignored based on patterns.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type FilesConfig

type FilesConfig struct {
	// Extensions defines which file extensions to process
	Extensions []string `yaml:"extensions" json:"extensions"`
	// IgnorePatterns defines glob patterns to ignore
	IgnorePatterns []string `yaml:"ignore_patterns" json:"ignore_patterns"`
}

FilesConfig contains file processing options

type HeadingConfig

type HeadingConfig struct {
	// Style defines the heading style: "atx" (#) or "setext" (===)
	Style string `yaml:"style" json:"style"`
	// NormalizeLevels fixes heading level jumps
	NormalizeLevels bool `yaml:"normalize_levels" json:"normalize_levels"`
}

HeadingConfig contains heading formatting options

type ListConfig

type ListConfig struct {
	// BulletStyle defines the bullet character: "-", "*", or "+"
	BulletStyle string `yaml:"bullet_style" json:"bullet_style"`
	// NumberStyle defines the numbering style: "." or ")"
	NumberStyle string `yaml:"number_style" json:"number_style"`
	// ConsistentIndentation ensures consistent indentation
	ConsistentIndentation bool `yaml:"consistent_indentation" json:"consistent_indentation"`
}

ListConfig contains list formatting options

type WhitespaceConfig

type WhitespaceConfig struct {
	// MaxBlankLines defines maximum consecutive blank lines
	MaxBlankLines int `yaml:"max_blank_lines" json:"max_blank_lines"`
	// TrimTrailingSpaces removes trailing spaces
	TrimTrailingSpaces bool `yaml:"trim_trailing_spaces" json:"trim_trailing_spaces"`
	// EnsureFinalNewline ensures files end with a newline
	EnsureFinalNewline bool `yaml:"ensure_final_newline" json:"ensure_final_newline"`
}

WhitespaceConfig contains whitespace handling options

Jump to

Keyboard shortcuts

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