Expand description
Dual-style formatter (C-022).
Re-emits a parsed module in brace style, indentation style, or the source’s own style, preserving every comment (with its normative attachment, spec/dual-syntax.md §7) and canonical blank-line structure.
Canonical layout (spec §8):
- indentation style: two spaces per level,
key:headers; - brace style:
[name]headers at the top level,key = valuepairs, nested tables asname { … }blocks; - no blank lines inside a block; one blank line between top-level entries when either side is a table;
- a leading comment sits directly above its statement, a trailing comment on the same line after the value.
The guarantees tested in C-022 are: idempotence (fmt(fmt(d)) == fmt(d)),
byte-for-byte preservation of canonical documents, and comment survival
in every mode.
Functions§
- format
- Format a module in the requested style.
Preserveuses the style the source predominantly used.