Detect bytes before decoding text
MDLoom rejects binary signatures, NUL-heavy content, malformed UTF-16, invalid UTF-8 when fallback is disabled, and oversized sources. BOM-aware UTF-8, UTF-16LE, and UTF-16BE are decoded strictly; Windows-1252 fallback is explicit and warning-bearing.
Preserve exact original bytes until the source is edited
An imported file retains a defensive copy of its bytes, detected encoding, BOM, and preferred line ending. An unedited source download can return those bytes exactly; after an edit, deterministic encoding uses the recorded policy.
Treat line endings as source metadata
LF, CRLF, CR, and mixed files are distinguished. Normal editing should not normalize an entire document invisibly. The explicit formatter can preserve the detected convention or deliberately choose LF or CRLF with a visible source diff.
Investigate replacement characters instead of accepting them
A replacement glyph can mean the wrong decoder, corrupt bytes, or a font coverage problem. Compare the original byte hash, detected encoding, source text, preview glyph, and generated artifact separately before deciding which layer is wrong.