Expand description
Content-type detection and pretty-printing for structured data.
Used by --prettify and --content-type to lay out JSON, YAML, TOML,
XML, HTML, and CSV inputs in a readable form. The transformation runs once
at startup (or on toggle) and produces a fresh byte buffer that the line
index treats as the new source content. No syntax highlighting / color —
layout only — so search and filter stay byte-clean.
Enums§
- Prettify
Mode - Resolved
Type - Result of resolving the user’s content-type intent against the available signals (explicit flag → extension → byte sniff → raw fallback).
Functions§
- detect_
from_ bytes - Detect from leading bytes. Returns
Noneif nothing matches. Cheap; inspects up to ~512 bytes. - detect_
from_ path - Detect from filename extension. Returns
Noneif nothing matches. - parse_
content_ type - Parse a
--content-type=NAMEvalue. Case-insensitive.autoreturnsNone(caller should run detection);rawmaps toOff. - prettify
- Run the transform for
modeoverinput.Offreturns the input verbatim (still allocates — callers can short-circuit if they care). On parse failure, returns the error string for the status line. - resolve
- Combined resolver: explicit override (already parsed) → path extension → byte sniff → undetected.