Documentation
¶
Overview ¶
Package termsafe makes text from a document safe to show on a terminal by turning the characters a terminal acts on into text.
A block's code is shown so its reader can decide whether to run it. Escape sequences and other control characters in it would be acted on instead of shown: "\r\x1b[2K" at the end of a line erases what came before it, so code could run that its reader never saw. Visible shows such characters instead, so what is on the screen is what runs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasControl ¶
HasControl reports whether s has a character Visible would replace.
func Visible ¶
Visible returns s with every control character other than newline and tab replaced by a visible stand-in: C0 controls in caret notation (ESC as ^[, CR as ^M), DEL as ^?, and as <U+XXXX> the C1 controls, the Unicode direction overrides that can reorder how a line reads, and the zero-width characters that can hide inside a word. Text without such characters is returned as it is. A byte that isn't valid UTF-8 shows as <0xXX>, since a lone 0x9b is a CSI to some terminals.
Types ¶
This section is empty.