texts

package
v0.0.0-...-c369810 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dedent

func Dedent(text string) string

Dedent removes leading whitespace indentation from each line in the text.

Whitespace is removed according to smallest whitespace prefix of a determining line. A determining line is a line that has at least 1 non-space character. The algorithm is:

- If the first line is whitespace, discard it. - If the last line is whitespace, discard it. - For each remaining line:

  • If the line only has whitespace, replace it with a single newline.
  • If the line has non-whitespace chars, find the common whitespace prefix of all such lines.

- Remove the common whitespace prefix from each line.

Types

This section is empty.

Jump to

Keyboard shortcuts

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