marco_core/render/mod.rs
1//! HTML renderer entry points and render support modules.
2//!
3//! This module exposes the stable rendering API used by consumers:
4//! [`render()`] and [`RenderOptions`].
5
6/// Base stylesheet used by preview rendering.
7pub mod base_css;
8/// Language normalization and metadata for code blocks.
9pub mod code_languages;
10/// Diagram rendering helpers (for example Mermaid).
11#[cfg(feature = "render-diagrams")]
12pub mod diagram;
13/// Core Markdown AST to HTML renderer.
14pub mod markdown;
15/// Math rendering helpers.
16#[cfg(feature = "render-math")]
17pub mod math;
18/// Public render configuration options.
19pub mod options;
20/// Platform mention rendering helpers.
21pub mod plarform_mentions;
22/// HTML document wrappers for preview pages.
23pub mod preview_document;
24/// Syntax highlighting support based on syntect.
25#[cfg(feature = "render-syntax-highlighting")]
26pub mod syntect_highlighter;
27/// Theme metadata: parses `--theme-*` descriptive tokens from theme CSS.
28pub mod theme_meta;
29
30/// Re-export code language helpers.
31pub use code_languages::*;
32/// Re-export core HTML render helpers.
33pub use markdown::*;
34/// Re-export render options.
35pub use options::*;
36/// Re-export preview document helpers.
37pub use preview_document::*;
38/// Re-export syntax highlighter helpers.
39#[cfg(feature = "render-syntax-highlighting")]
40pub use syntect_highlighter::*;
41/// Re-export theme metadata helpers.
42pub use theme_meta::*;
43
44use crate::parser::Document;
45
46/// Render a parsed Markdown [`Document`] into HTML.
47pub fn render(
48 document: &Document,
49 options: &RenderOptions,
50) -> Result<String, Box<dyn std::error::Error>> {
51 log::info!("Starting HTML render");
52 let html = render_html(document, options)?;
53 log::debug!("Generated {} bytes of HTML", html.len());
54 Ok(html)
55}