Skip to main content

Crate mdcast

Crate mdcast 

Source
Expand description

mdcast — Markdown → DOCX/PDF/PPTX/HTML with per-page layout templates.

Re-exports§

pub use assets::AssetProvider;
pub use assets::BoxFuture;
pub use assets::EmbeddedAssets;
pub use assets::LayeredAssets;
pub use assets::async_provider;
pub use assets::sync_provider;
pub use brand::AutoLayout;
pub use brand::BrandSpec;
pub use pages::splitter::DefaultSplitter;
pub use pages::splitter::PageSplitter;
pub use pages::Page;
pub use pages::PageOrigin;
pub use pages::RawPage;
pub use preprocessor::Chain;
pub use preprocessor::HtmlImageTags;
pub use preprocessor::Identity;
pub use preprocessor::MarkdownPreprocessor;

Modules§

assets
Asset resolution. Backends fetch templates, reference docs, images, etc. through this trait — never std::fs. The default impl bakes the built-in catalog in via rust-embed; consumers wrap or replace it.
backends
Backend registry. Per-target dispatch sits in Registry::render; backends themselves are feature-gated so a consumer can build with only what they need.
brand
Brand specification: single source of truth for palette, fonts, margins, and the auto-layout rules. v1 only models what the page-layout system needs; richer projection (palette → typst/CSS/reference docs) lands in Phase 4.
frontmatter
Strip a leading YAML frontmatter block (------) off a markdown document and parse it into a DocMeta, before PageSplitter ever sees the document — otherwise the splitter reads the closing fence as a thematic break and the frontmatter becomes a phantom hero page.
images
Resolve markdown image references through the AssetProvider.
mermaid
Mermaid → SVG pre-step (mermaid feature).
pages
Page-aware IR for the doc body. Stage 1 (splitter) parses the surface syntaxes into RawPages; stage 2 (auto) assigns a class to produce Pages ready for backends.
preprocessor
User-pluggable markdown preprocessor.

Structs§

Artifact
What a backend produced, written to disk. Backends may write multiple files (e.g. HTML + assets); the primary artifact is the one a caller should hand back to the user.
AssetRef
Reference to an external asset that the renderer should resolve via the AssetProvider (e.g. an SVG rendered from a Mermaid pre-step, or a brand logo a typst layout wants to place outside the page body). Consumed today by the typst backend only: each entry is fetched through the provider and registered as a virtual file layouts can reach via #import "/context.typ": asset-path (see README’s “Typst layout context”). Pandoc backends ignore this field — they already resolve images referenced from markdown bodies via images::resolve_images.
BrandHandle
Opaque handle into a BrandSpec so backends don’t carry the whole spec around.
DocMeta
Document-level metadata extracted from frontmatter / config.
RenderRequest
Per-render input passed to the path-based render entry point. Holds the doc, the asset provider, and the destination path. Borrowed so the renderer never owns runtime state.
RenderedArtifact
What a backend produced, held entirely in memory — the shape a server embedder wants to hand straight back in an HTTP response body, with no temp file to mint or clean up.
ResolvedDoc
The pipeline currency. OUR type — never pandoc’s AST.

Enums§

Target
Output target. One backend per variant.

Traits§

Backend
Every output format is one impl. Pandoc is just one kind of guest. Async because resolving templates and engine subprocesses are inherently async.