Skip to main content

Crate mbook

Crate mbook 

Source
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:

  • BookReader reads a book lazily from anything that can seek. Opening it reads the tables; each chapter, picture, diagram and formula is decoded when asked for.
  • Book is 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

FeatureDefaultEnables
readyesBookReader, Book::read, Book::open
writeyesBook::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.
BookReader
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.
ChapterEntry
One chapter, as listed by a BookReader.
ChapterId
Identifies a chapter inside one mbook file.
Diagram
One diagram of a Book: a path and a description in Mermaid notation.
DiagramEntry
One diagram, as listed by a BookReader.
DiagramId
Identifies a diagram inside one mbook file.
Formula
One formula of a Book: a path and a formula in the notation of KaTeX, without the $ that surround one in running text.
FormulaEntry
One formula, as listed by a BookReader.
FormulaId
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.
LandmarkEntry
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.
PictureEntry
One picture, as listed by a BookReader.
PictureId
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.
ReadOptions
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.
TextError
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.
WriteOptions
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.
LandmarkError
Why the landmarks of a book were refused.
MetaError
Why a change to the metadata was refused.
PathError
Why a path was refused.
ProblemKind
What is wrong with a book.
ResolveError
Why a link or picture destination leads nowhere.
ResourceKind
What a resource holds, as declared by the resource table.
SourceError
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.