Back to godoc.org

Package text

v0.0.0-...-1557bcf
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Index

Examples

func Doc

func Doc(doc string) string

Doc transforms doc:

1. Strips leading and trailing whitespace.
2. Removes common '\t' indentation.
3. Replaces '\n' not-followed by whitespace with ' '.

See example.

This function is not fast.

Example

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.



	`))
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.
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier