text

package
v0.20.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2016 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

README

This is a Go package for manipulating paragraphs of text.

See http://go.pkgdoc.org/github.com/kr/text for full documentation.

Documentation

Overview

Package text provides rudimentary functions for manipulating text in paragraphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indent

func Indent(s, prefix string) string

Indent inserts prefix at the beginning of each non-empty line of s. The end-of-line marker is NL.

func IndentBytes

func IndentBytes(b, prefix []byte) []byte

IndentBytes inserts prefix at the beginning of each non-empty line of b. The end-of-line marker is NL.

func NewIndentWriter

func NewIndentWriter(w io.Writer, pre ...[]byte) io.Writer

NewIndentWriter makes a new write filter that indents the input lines. Each line is prefixed in order with the corresponding element of pre. If there are more lines than elements, the last element of pre is repeated for each subsequent line.

func Wrap

func Wrap(s string, lim int) string

Wrap wraps s into a paragraph of lines of length lim, with minimal raggedness.

func WrapBytes

func WrapBytes(b []byte, lim int) []byte

WrapBytes wraps b into a paragraph of lines of length lim, with minimal raggedness.

func WrapWords

func WrapWords(words [][]byte, spc, lim, pen int) [][][]byte

WrapWords is the low-level line-breaking algorithm, useful if you need more control over the details of the text wrapping process. For most uses, either Wrap or WrapBytes will be sufficient and more convenient.

WrapWords splits a list of words into lines with minimal "raggedness", treating each byte as one unit, accounting for spc units between adjacent words on each line, and attempting to limit lines to lim units. Raggedness is the total error over all lines, where error is the square of the difference of the length of the line and lim. Too-long lines (which only happen when a single word is longer than lim units) have pen penalty units added to the error.

Types

This section is empty.

Directories

Path Synopsis
Package colwriter provides a write filter that formats input lines in multiple columns.
Package colwriter provides a write filter that formats input lines in multiple columns.
Command mc prints in multiple columns.
Command mc prints in multiple columns.

Jump to

Keyboard shortcuts

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