Method CanRead
CanRead(Stream)
Sniffs whether a stream looks like Markdown, restoring its position before returning.
public bool CanRead(Stream stream)
Parameters
streamStreamThe seekable stream to sniff.
Returns
Remarks
Markdown has no signature, and every plain-text file is valid Markdown — so a sniff that accepted anything decodable would claim every stream no other reader recognized, and a corrupt DOCX would silently become a document full of mojibake instead of an error. The probe therefore requires a positive signal: an ATX heading, a fenced code block, a setext underline, a thematic break, a list marker or a link reference definition at the start of a line within the first four kilobytes.
The consequence is stated rather than hidden: a Markdown file that is nothing but prose
is not auto-detected. It loads by extension or by passing
FormatDetection.Markdown, and reading it as plain text would in any case have
produced the same document.
Exceptions
- ArgumentNullException
streamis null.- ArgumentException
The stream is not seekable.