Expand description
Read, edit and create mbook files.
An mbook file holds a book as Markdown chapters and AVIF pictures, with
diagrams in Mermaid notation, formulas in the notation of KaTeX, and
small tables that describe it. The format is specified by RFC 0001, in the
docs/src/rfcs folder of the repository, and this API is described in
docs/src/mbook.
Two types do the work:
BookReaderreads a book lazily from anything that can seek. Opening it reads the tables; each chapter, picture, diagram and formula is decoded when asked for.Bookis a whole book in memory. It is how a book is created and how an existing one is changed.
A source that cannot seek is served by both: BookReader::buffered keeps
the compressed bytes in memory and still decodes on demand, and
Book::read decodes everything in one pass.
§Features
| Feature | Default | Enables |
|---|---|---|
read | yes | BookReader, Book::read, Book::open |
write | yes | Book::new and everything that changes or saves a Book |
At least one of them must be enabled.
Structs§
- Anchor
- A named place inside a chapter, the target of a link fragment.
- Book
- A whole book in memory: metadata, chapters in reading order, pictures, diagrams, formulas and the table of contents.
- Book
Reader - Reads a book lazily from anything that can seek.
- Chapter
- One chapter of a
Book: a path, Markdown text, the anchors of its headings and the extra anchors of the lines it names. - Chapter
Entry - One chapter, as listed by a
BookReader. - Chapter
Id - Identifies a chapter inside one mbook file.
- Diagram
- One diagram of a
Book: a path and a description in Mermaid notation. - Diagram
Entry - One diagram, as listed by a
BookReader. - Diagram
Id - Identifies a diagram inside one mbook file.
- Formula
- One formula of a
Book: a path and a formula in the notation ofKaTeX, without the$that surround one in running text. - Formula
Entry - One formula, as listed by a
BookReader. - Formula
Id - Identifies a formula inside one mbook file.
- Landmark
- One landmark of a
Book: a notable place, such as the start of the text, the glossary or the index. - Landmark
Entry - One landmark, as stored in a file: a notable place of the book, such as the start of its text or its index.
- Limits
- Bounds applied before memory is allocated from lengths found in a file.
- Meta
- The metadata of a book: its title, languages, authors and the rest.
- Picture
- One picture of a
Book: a path and an AVIF file. - Picture
Entry - One picture, as listed by a
BookReader. - Picture
Id - Identifies a picture inside one mbook file.
- Position
- A place inside a chapter.
- Problem
- One problem found when checking a book.
- Problems
- Every problem that keeps a book from being written.
- Read
Options - How a book is read. Start from
ReadOptions::default. - Resource
- One row of the resource table, for tools that list a whole file.
- Series
- The series a book belongs to.
- Size
- The size of a picture in pixels, as displayed.
- Text
Error - A character that a chapter, a diagram or a formula must not contain.
- TocEntry
- One entry of the table of contents, as stored in a file.
- TocItem
- One item of an explicit table of contents.
- Version
- The version of the mbook format a file declares.
- Write
Options - How a book is written. Start from
WriteOptions::default.
Enums§
- Destination
- What a link or picture destination in a chapter points to.
- Error
- Why an operation on a book failed.
- Landmark
Error - Why the landmarks of a book were refused.
- Meta
Error - Why a change to the metadata was refused.
- Path
Error - Why a path was refused.
- Problem
Kind - What is wrong with a book.
- Resolve
Error - Why a link or picture destination leads nowhere.
- Resource
Kind - What a resource holds, as declared by the resource table.
- Source
Error - Why the source of a diagram or of a formula was refused.
- Toc
- The table of contents of a
Book.
Functions§
- is_
mbook - Tells whether a file looks like an mbook file from its first bytes.
Type Aliases§
- Result
- The result type of this crate.