Documentation
¶
Overview ¶
Package codetext loads and normalizes user-supplied text/code for the Code typing mode. It is the I/O boundary for `--text <file>` / `--text -` so the pure-logic packages (words, typing) stay free of file/stdin access.
Normalization (full-literal-safe): strip a leading UTF-8 BOM, convert CRLF to LF, and trim exactly one trailing newline (so the snippet's final line needs no closing Enter). Tabs, interior blank lines, and indentation are preserved verbatim — Code mode requires the user to type them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmpty = errors.New("codetext: input is empty or whitespace-only") ErrBinary = errors.New("codetext: input is not valid UTF-8 text") ErrTooLarge = errors.New("codetext: input exceeds the size limit") )
Sentinel causes; callers branch with errors.Is to show a precise hint.
Functions ¶
func Load ¶
Load reads from a file path, or from stdin when path == "-", then normalizes and validates. The returned string is ready to use as a Code target verbatim.
func Normalize ¶ added in v1.3.0
Normalize applies the exact same BOM/binary/CRLF/trim/empty/cap pipeline as Load to an already in-memory string (no file I/O). It exists so an in-app paste is validated by identical rules/caps as `--text` — Load and Normalize share the single normalize core below, so the rules cannot diverge.
Types ¶
This section is empty.