text

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package text reads text documents as UTF-8, from whatever character set they're in, and writes plain text as Markdown, so it's shown as it is

Index

Constants

View Source
const (
	// MaxBytes is the most of a text document which is read, as the
	// document is decoded, or parsed, in memory. A larger document is read
	// up to this size.
	MaxBytes = 16 << 20
)

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte, cut bool) (string, error)

Decode returns the text as UTF-8, from the character set of its byte order mark, or UTF-8 when it's valid UTF-8, or else Windows-1252. When the text was cut off, a character cut off at its end is removed first, so it isn't read as invalid UTF-8.

func Escape

func Escape(text string) string

Escape returns the text as Markdown within a line, such as a cell of a table, with its characters which are Markdown escaped, and its line breaks and tabs as spaces

func PlainText

func PlainText(value string) string

PlainText returns text which may be HTML, such as a description, as plain text, without its tags, with its entities decoded, and its spaces collapsed

func Read

func Read(r io.Reader) (string, error)

Read returns at most MaxBytes of the text as UTF-8, from the character set of its byte order mark, or UTF-8 when it's valid UTF-8, or else Windows-1252

func WriteMarkdown

func WriteMarkdown(w io.StringWriter, text string) error

WriteMarkdown writes the text as Markdown, a line at a time, so it's shown as it is: its characters which are Markdown are escaped, its line breaks are kept, a blank line separates its paragraphs, and its indentation is kept without the line being code. It stops when a write returns an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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