Skip to main content

marco_core/
lib.rs

1//! `marco-core` is a pure-Rust Markdown engine with editor intelligence.
2//!
3//! Typical flow:
4//! 1. Parse input text into an AST with [`parse`].
5//! 2. Render the AST to HTML with [`render()`].
6//! 3. Optionally run editor analysis via [`MarkdownIntelligenceProvider`].
7//!
8//! # Example
9//! ```rust
10//! let doc = marco_core::parse("# Hello")?;
11//! let html = marco_core::render(&doc, &marco_core::RenderOptions::default())?;
12//! assert!(html.contains("<h1"));
13//! assert!(html.contains("Hello"));
14//! # Ok::<(), Box<dyn std::error::Error>>(())
15//! ```
16
17/// The crate version from `Cargo.toml`, exposed for downstream UIs and diagnostics.
18pub const VERSION: &str = env!("CARGO_PKG_VERSION");
19
20/// Low-level Markdown grammar components (block and inline parsers).
21pub mod grammar;
22/// Editor intelligence APIs such as diagnostics, highlights, completions, and TOC.
23pub mod intelligence;
24/// Utility logic such as UTF-8 sanitization and text helpers.
25pub mod logic;
26/// AST definitions and parser entry points.
27pub mod parser;
28/// HTML rendering and rendering options.
29pub mod render;
30
31/// Main intelligence provider used by downstream editor integrations.
32pub use intelligence::MarkdownIntelligenceProvider;
33/// Parse Markdown text into a [`Document`] AST using default options.
34pub use parser::parse;
35/// Parse Markdown with explicit runtime options (position tracking, math, diagrams).
36pub use parser::parse_with_options;
37/// Runtime parse configuration; pass to [`parse_with_options`] to skip expensive work.
38pub use parser::ParseOptions;
39/// Core AST types used by parser, renderer, and intelligence modules.
40pub use parser::{Document, Node, NodeKind};
41/// Render a parsed [`Document`] into HTML using [`RenderOptions`].
42pub use render::{render, RenderOptions};
43
44/// UTF-8 sanitization API and related types.
45pub use logic::utf8::{sanitize_input, sanitize_input_with_stats, InputSource, SanitizeStats};