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
28/// Re-export code language helpers.
29pub use code_languages::*;
30/// Re-export core HTML render helpers.
31pub use markdown::*;
32/// Re-export render options.
33pub use options::*;
34/// Re-export preview document helpers.
35pub use preview_document::*;
36/// Re-export syntax highlighter helpers.
37#[cfg(feature = "render-syntax-highlighting")]
38pub use syntect_highlighter::*;
39
40use crate::parser::Document;
41
42/// Render a parsed Markdown [`Document`] into HTML.
43pub fn render(
44 document: &Document,
45 options: &RenderOptions,
46) -> Result<String, Box<dyn std::error::Error>> {
47 log::info!("Starting HTML render");
48 let html = render_html(document, options)?;
49 log::debug!("Generated {} bytes of HTML", html.len());
50 Ok(html)
51}