Skip to main content

Module textops

Module textops 

Source
Expand description

Text operations on a selection: sorting and de-duplicating lines, changing case, trimming, converting indentation, and re-formatting JSON. They work on decoded text and keep the text’s own line breaks; the caller applies the result as one undoable edit, or, for a document of any size, text_op_to streams it to a file.

Structs§

JsonFormatter
json_format a piece at a time: what it has seen is carried from one piece to the next.

Enums§

Op

Constants§

WINDOW
Bytes decoded, changed and written at a time (whole lines).

Functions§

apply
codec_apply
A decoding or encoding of text: the bytes it gives (decoded bytes need not be text).
json_format
Re-formats JSON token by token: key order, numbers and string escapes stay exactly as written. Several top-level values (JSON Lines) stay on separate lines. With indent the output is indented, otherwise all insignificant whitespace is removed.
text_op_to
Writes buf with op applied to range (the rest as it is) to out, whole lines at a time, for documents of any size. Returns the bytes written, or None when cancelled.