Skip to content

openMarkdownFile

openMarkdownFile(bytes): MarkdownFile

Open a Markdown file's bytes for the editor. Decodes strict UTF-8 (invalid bytes throw InvalidUtf8Error; nothing is replaced), notes and strips a leading BOM, detects the line endings (LF, CRLF, lone CR, or a mix) and turns them into \n, and keeps a copy of the original bytes. Save with saveMarkdownFile.

Uint8Array

The file as read from disk, a network response or a file input.

MarkdownFile

The text to edit, and what saving needs to write the file back.

InvalidUtf8Error when bytes is not valid UTF-8.