Skip to main content

Crate carta

Crate carta 

Source
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.
DocxOptions
Options for the DOCX container writer. Ignored by every other writer. The default produces a self-contained document from the built-in template, with reproducible property timestamps and a language tag drawn from the document or the environment.
EpubOptions
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 in Extension::ALL.
HighlightOptionshighlight
The syntax-highlighting configuration attached to WriterOptions, and the catalog the CLI draws its language and style listings from. Syntax-highlighting configuration for the writers that colorize code blocks (the HTML family, LaTeX, and DOCX). The default leaves code blocks unhighlighted.
Highlighterhighlight
Tokenizes source code using a catalog of syntax definitions.
MediaBag
A document’s embedded resources, keyed by the name the document references each one under.
MediaItem
One entry in a MediaBag: a resource’s bytes together with its MIME type, when the source recorded one.
ReaderOptions
Options controlling a Reader. Extended (not resignatured) as real options land.
Resourcewrite-html
The post-render pass that inlines an HTML page’s external resources as data: URIs and inline <style>/<script> elements, together with the resolved-resource type it consumes. Drives the CLI’s self-contained HTML output. A resolved resource: its bytes and, when the resolver could determine one, its MIME type.
Themehighlight
A complete color theme.
WriterOptions
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::ALL is its bit index in Extensions.
MathMethod
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.math and 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.
WrapMode
How a text writer lays out the lines of a paragraph.

Traits§

BytesReader
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.
BytesWriter
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.
builtin_stylehighlight
Retrieve a built-in theme by name.
convert
Converts raw input bytes from format from to format to, returning text for a text target and bytes for a byte-shaped one.
convert_text
Converts text input from format from to text in format to.
format_extensions
Lists the extensions a format admits, each paired with whether it is enabled by default.
inline_resourceswrite-html
The post-render pass that inlines an HTML page’s external resources as data: URIs and inline <style>/<script> elements, together with the resolved-resource type it consumes. Drives the CLI’s self-contained HTML output. Inline every external resource an HTML document references, producing a self-contained page.
input_format_names
Every accepted Reader format name in this build — canonical names and their aliases — sorted.
languageshighlight
The names of the languages offered in listings, in published order.
merge_metadatastandalone
Folds the extra metadata layers carried in writer_options into document.meta: the metadata-file defaults sit below the document’s own values, and the -M layer 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 Extensions it selects.
parse_metadata_filemetadata-file
Parses a metadata file into a metadata map, for use as WriterOptions::metadata_defaults.
read_document
Parses input in format from into 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 of any_reader_for.
render_document
Renders document into format to, returning text for a text target and bytes for a byte-shaped one. media supplies 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.
styleshighlight
The names of the built-in color themes, in published order.
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 of any_writer_for.

Type Aliases§

Result
A Result whose error is Error.