lib

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatComments

func FormatComments(lines []string) string

func FormatFileLines

func FormatFileLines(fileLines []string, c *Config) string

func FormatNode

func FormatNode(ast *ExtendedNode, c *Config) (string, bool)

func FormatOnBuild

func FormatOnBuild(n *ExtendedNode, c *Config) string

func GetFileLines

func GetFileLines(fileName string) ([]string, error)

func GetHeredoc

func GetHeredoc(n *ExtendedNode) (string, bool)

func IndentFollowingLines

func IndentFollowingLines(lines string, indentSize uint) string

func Marshal

func Marshal(i interface{}) ([]byte, error)

Marshal is a UTF-8 friendly marshaler. Go's json.Marshal is not UTF-8 friendly because it replaces the valid UTF-8 and JSON characters "&". "<", ">" with the "slash u" unicode escaped forms (e.g. \u0026). It preemptively escapes for HTML friendliness. Where text may include any of these characters, json.Marshal should not be used. Playground of Go breaking a title: https://play.golang.org/p/o2hiX0c62oN Source: https://stackoverflow.com/a/69502657/5684541

func StripWhitespace

func StripWhitespace(lines string, rightOnly bool) string

Types

type Config

type Config struct {
	IndentSize      uint
	TrailingNewline bool
	SpaceRedirects  bool
}

type ExtendedNode

type ExtendedNode struct {
	*parser.Node
	Children          []*ExtendedNode
	Next              *ExtendedNode
	OriginalMultiline string
}

func BuildExtendedNode

func BuildExtendedNode(n *parser.Node, fileLines []string) *ExtendedNode

type ParseState

type ParseState struct {
	CurrentLine int
	Output      string
	// Needed to pull in comments
	AllOriginalLines []string
	Config           *Config
}