transform

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package transform defines text rules and tree transforms. Import text rules run before parsing, and export text rules run after rendering. Tree transforms run after parsing or before rendering.

A text rule maps one line to one line, so every rule preserves the line count and diagnostic lines always refer to the input file. Rules that would remove a line blank it instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyText

func ApplyText(rules []TextRule, text string) string

ApplyText runs rules left-to-right over each line, preserving the line count.

func ApplyTree

func ApplyTree(transforms []TreeTransform, cfg *tree.Config)

ApplyTree runs tree transforms left-to-right.

Types

type TextRule

type TextRule interface {
	Apply(line string) string
}

TextRule transforms one line of raw configuration text before parsing or after rendering.

func DropLines

func DropLines(pattern string) (TextRule, error)

DropLines blanks matching lines to preserve source line numbers; export rules retain the blank lines.

func PerLineSub

func PerLineSub(pattern, repl string) (TextRule, error)

PerLineSub applies a regex substitution to each line independently.

type TreeTransform

type TreeTransform interface {
	Apply(cfg *tree.Config)
}

TreeTransform mutates a parsed tree.

Jump to

Keyboard shortcuts

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