Expand description
carta — a document converter library.
The public entry points: convert handles any format pair, taking raw bytes and returning an
Output that is text or bytes depending on the target format’s wire shape; convert_text is
a shortcut for when both sides are text. Formats are selected
at compile time via per-direction Cargo features (read-*/write-*);
supported_input_formats/supported_output_formats report what this build contains. For
lower-level use, the document model is re-exported as ast, and reader_for/writer_for
hand back the Reader/Writer trait objects so callers can inspect or transform the
Document directly.
Re-exports§
pub use carta_ast as ast;
Modules§
- media
- The media bag: a document’s embedded resources — images and other binary payloads — carried alongside the syntax tree rather than inside it.
- presets
- Per-flavor extension sets.
- walk
- Mutable traversals over the document model.
Structs§
- Document
- A whole document: schema version, metadata, and the block sequence.
- Epub
Options - Options for the EPUB container writer. Ignored by every other writer. The default is an empty book: no cover, no embedded fonts, the built-in stylesheet only, and chapters split at the top heading level.
- Extensions
- A deterministic, allocation-free set of
Extensions, backed by a fixed array of 64-bit words indexed by each variant’s position inExtension::ALL. - Media
Bag - A document’s embedded resources, keyed by the name the document references each one under.
- Media
Item - One entry in a
MediaBag: a resource’s bytes together with its MIME type, when the source recorded one. - Reader
Options - Options controlling a
Reader. Extended (not resignatured) as real options land. - Writer
Options - Options controlling a
Writer. Extended (not resignatured) as real options land.
Enums§
- AnyReader
- A resolved reader, either text-shaped (
Reader) or byte-shaped (BytesReader). - AnyWriter
- A resolved writer, either text-shaped (
Writer) or byte-shaped (BytesWriter). - Error
- The error type returned across the conversion pipeline.
- Extension
- A single format extension. Each variant’s position in
Extension::ALLis its bit index inExtensions. - Math
Method - How math is presented by a format that offers a choice of renderers (the HTML family). The
method decides both the inline markup inside a
span.mathand which loader a standalone document pulls in to typeset it: a MathJax (or plain) document carries the source TeX wrapped in\(…\)/\[…\], whereas a KaTeX document carries the bare TeX, which its in-browser loader reads from the span directly. - Output
- The output of a conversion: text from a text writer, bytes from a byte-shaped writer.
- TocStyle
- How a writer supplies a table of contents.
- Wrap
Mode - How a text writer lays out the lines of a paragraph.
Traits§
- Bytes
Reader - Parses input bytes in some source format into the document model. The byte-shaped counterpart of
Reader, for formats whose wire form is not text — zip containers and the like. - Bytes
Writer - Renders the document model into some target format’s bytes. The byte-shaped counterpart of
Writer, for formats whose output is not text — zip containers and the like. - Reader
- Parses input text in some source format into the document model.
- Writer
- Renders the document model into some target format’s text.
Functions§
- any_
reader_ for - Resolves a format name to its
AnyReader. - any_
writer_ for - Resolves a format name to its
AnyWriter. - convert
- Converts raw
inputbytes from formatfromto formatto, returning text for a text target and bytes for a byte-shaped one. - convert_
text - Converts text
inputfrom formatfromto text in formatto. - format_
extensions - Lists every extension carta models, each paired with whether
formatenables it by default. - input_
format_ names - Every accepted Reader format name in this build — canonical names and their aliases — sorted.
- merge_
metadata standalone - Folds the extra metadata layers carried in
writer_optionsintodocument.meta: the metadata-file defaults sit below the document’s own values, and the-Mlayer above them. - output_
format_ names - Every accepted Writer format name in this build — canonical names and their aliases — sorted.
- parse_
format_ spec - Splits a format specifier into its base name and the
Extensionsit selects. - parse_
metadata_ file metadata-file - Parses a metadata file into a metadata map, for use as
WriterOptions::metadata_defaults. - read_
document - Parses
inputin formatfrominto the document model together with the embedded resources it references (a notebook’s image outputs; empty for a format that carries none). - reader_
for - Resolves a format name to its boxed
Reader, the text-only view ofany_reader_for. - render_
document - Renders
documentinto formatto, returning text for a text target and bytes for a byte-shaped one.mediasupplies the embedded resources a re-embedding writer (a notebook re-encoding its image outputs) draws on; pass an empty bag when the document references none. - supported_
input_ formats - The canonical names of every compiled-in Reader format, in declaration order.
- supported_
output_ formats - The canonical names of every compiled-in Writer format, in declaration order.
- writer_
for - Resolves a format name to its boxed
Writer, the text-only view ofany_writer_for.