A real parse protects scalar meaning
Replacing spaces line by line cannot reliably distinguish indentation from whitespace inside block scalars or quoted text. The formatter parses the YAML data model first and writes one consistent representation only after the document is valid.
The selected indentation changes visual nesting. It does not sort mapping keys, reorder sequences, merge documents, or apply an application schema.