Versions in this module Expand all Collapse all v0 v0.1.0 Aug 22, 2023 Changes in this version + const DefaultIndentLevel + var DefaultDedentSpaceRegEx = regexp.MustCompile(`^([\s]+)`) + var DefaultMapfileEndRegEx = regexp.MustCompile(`mapfile.end`) + var DefaultMapfileStartRegEx = regexp.MustCompile(`mapfile:([^\s]+)`) + var DefaultMaprangeEndRegEx = regexp.MustCompile(`maprange.end`) + var DefaultMaprangeStartRegEx = regexp.MustCompile(`maprange:([^\s]+)`) + var DefaultRangeImportEndRegEx = regexp.MustCompile(`range.end`) + var DefaultRangeImportStartRegEx = regexp.MustCompile(`range:(?P<Cue>[^\s]+)`) + type Config struct + Mapfile *MapfileDirective + Maprange *MaprangeDirective + func LoadConfig(ctx context.Context, filePath string) (_ *Config, err error) + func (cfg *Config) LogValue() slog.Value + func (cfg *Config) ToProcessorConfig(ctx context.Context) (_ *ProcessorConfig, err error) + type DedentRuleConfig struct + SpaceRegExp *regexp.Regexp + type MapFileEndNode struct + type MapFileNode struct + ImportFile string + type MapfileDirective struct + DefaultSkip int + DisableRewriteIndent bool + EndRegExp string + IndentWidth int + StartRegExp string + func (d *MapfileDirective) LogValue() slog.Value + type MapfileRuleConfig struct + DefaultSkip int + EmbedRules []Rule + EndRegExp *regexp.Regexp + StartRegExp *regexp.Regexp + type MaprangeDirective struct + DefaultSkip int + DisableDedent bool + DisableRewriteIndent bool + EndRegExp string + IndentWidth int + StartRegExp string + func (d *MaprangeDirective) LogValue() slog.Value + type MaprangeRuleConfig struct + DefaultSkip int + EmbedRules []Rule + EndRegExp *regexp.Regexp + StartRegExp *regexp.Regexp + type Node interface + Text func() string + type Processor interface + Parse func(ctx context.Context, filePath string, r io.Reader) ([]Node, error) + ProcessFile func(ctx context.Context, filePath string) (string, error) + WithRules func(ctx context.Context, rules []Rule) (Processor, error) + func NewProcessor(cfg *ProcessorConfig) (Processor, error) + type ProcessorConfig struct + OpenFile func(filePath string) (io.Reader, error) + Rules []Rule + type RangeImportRuleConfig struct + EndRegExp *regexp.Regexp + Name string + StartRegExp *regexp.Regexp + type ReindentRuleConfig struct + IndentLevel int + type Rule interface + Apply func(ctx context.Context, opts *RuleOptions, nodes []Node) ([]Node, error) + func NewDedentRule(cfg *DedentRuleConfig) (Rule, error) + func NewMapfileRule(cfg *MapfileRuleConfig) (Rule, error) + func NewMaprangeRule(cfg *MaprangeRuleConfig) (Rule, error) + func NewRangeImportRule(cfg *RangeImportRuleConfig) (Rule, error) + func NewReindentRule(cfg *ReindentRuleConfig) (Rule, error) + type RuleOptions struct + OpenFile func(filePath string) (io.Reader, error) + Processor Processor + TargetPath string + func (opts *RuleOptions) FilePath(externalFilePath string) string