text

package
v0.126.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chomp added in v0.93.0

func Chomp(s string) string

Chomp removes trailing newline characters from s.

func Puts added in v0.93.0

func Puts(s string) string

Puts adds a trailing \n none found.

func RemoveAccents added in v0.62.2

func RemoveAccents(b []byte) []byte

RemoveAccents removes all accents from b.

func RemoveAccentsString added in v0.62.2

func RemoveAccentsString(s string) string

RemoveAccentsString removes all accents from s.

func VisitLinesAfter added in v0.100.0

func VisitLinesAfter(s string, fn func(line string))

VisitLinesAfter calls the given function for each line, including newlines, in the given string.

Types

type Position

type Position struct {
	Filename     string // filename, if any
	Offset       int    // byte offset, starting at 0. It's set to -1 if not provided.
	LineNumber   int    // line number, starting at 1
	ColumnNumber int    // column number, starting at 1 (character count per line)
}

Position holds a source position in a text file or stream.

func (Position) IsValid

func (pos Position) IsValid() bool

IsValid returns true if line number is > 0.

func (Position) String

func (pos Position) String() string

type Positioner

type Positioner interface {
	// Position returns the current position.
	// Useful in error logging, e.g. {{ errorf "error in code block: %s" .Position }}.
	Position() Position
}

Positioner represents a thing that knows its position in a text file or stream, typically an error.

Jump to

Keyboard shortcuts

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