Skip to main content

Module encoding

Module encoding 

Source
Expand description

MD094 reports input that is not valid UTF-8, and the decoder that reads it.

A document with a few invalid bytes (a Latin-1 é, a truncated sequence) is still Markdown: it is decoded lossily, each invalid sequence becomes one U+FFFD, the text is linted as usual, and MD094 reports every replacement at its position. Invalid input that looks binary (a NUL early on, or a UTF-16 byte order mark) is not linted at all, because lossy text from an image or archive yields hundreds of meaningless findings from other rules.

The lossy text is never written back: its U+FFFD characters stand for bytes the file really holds, so every adapter reports on it and leaves the file untouched.

Structs§

InvalidSeq
One invalid UTF-8 sequence in the original bytes.
MD094InvalidEncoding

Enums§

Decoded
The result of decoding a document’s bytes.

Constants§

MAX_REPORTED
How many invalid sequences are reported individually before the rest are summarized in one finding.
RULE_NAME

Functions§

decode
Decode a document’s bytes.
decode_owned
Decode owned bytes to text, None for binary input.
detect_binary_for_rules
The finding for a binary input, if the invocation reports MD094 for it.
guard_missing_from_document_rules
Whether a lossily decoded document needs MD094 added back to its rule set.
read_markdown_lossy
Read a Markdown file for indexing, decoding invalid UTF-8 lossily.
settle_lossy_warnings
Settle the report for a lossily decoded document.