luci: go.chromium.org/luci/common/data/text Index | Examples | Files | Directories

package text

import "go.chromium.org/luci/common/data/text"

Index

Examples

Package Files

document.go

func Doc Uses

func Doc(doc string) string

Doc transforms doc:

1. Strips leading and trailing blank lines.
2. Removes common '\t' indentation.
3. Replaces '\n' not-followed by whitespace with ' '.
4. Guarantees '\n' in the end.

See example.

This function is not fast.

Code:

fmt.Println(Doc(`
		Leading blank line above is removed.

		The indentation on the left is trimmed.

		These 2 lines appear on the same line,
		with a space instead of newline.

		A new paragraph is preserved.
			New line before indented text is preserved.
			Indentation of the intentionally indented text is preserved.

		Trailing blank lines is removed.



	`))

Output:

Leading blank line above is removed.

The indentation on the left is trimmed.

These 2 lines appear on the same line, with a space instead of newline.

A new paragraph is preserved.
	New line before indented text is preserved.
	Indentation of the intentionally indented text is preserved.

Trailing blank lines is removed.

Directories

PathSynopsis
color
indented
patternPackage pattern implements lightweight parsable string patterns.
sanitizehtmlPackage sanitizehtml implements a sanitizer of a very limited HTML.
stringtemplatePackage stringtemplate implements Python string.Template-like substitution.
templateprotoPackage templateproto defines a proto-based way to configure templates for JSON documents.
unitsPackage units provides common useful printable units.

Package text imports 3 packages (graph) and is imported by 5 packages. Updated 2019-05-23. Refresh now. Tools for package owners.