Skip to main content

dioxus_mdx/parser/
mod.rs

1//! MDX documentation parser for extracting frontmatter and components.
2//!
3//! This module provides functionality to parse MDX (Markdown with JSX) content,
4//! extracting YAML frontmatter and converting custom components like Cards, Tabs,
5//! Steps, and Callouts into an intermediate representation for rendering.
6
7mod accordion;
8mod callout;
9mod card;
10mod code_group;
11mod content;
12mod fields;
13mod frontmatter;
14mod openapi_parser;
15mod openapi_tag;
16mod openapi_types;
17mod steps;
18mod syntax;
19mod tabs;
20mod types;
21mod update;
22mod utils;
23
24pub use content::{get_raw_markdown, parse_mdx};
25pub use frontmatter::extract_frontmatter;
26pub use openapi_parser::{OpenApiError, parse_openapi};
27pub use openapi_types::*;
28pub use syntax::highlight_code;
29pub use types::*;
30
31/// Parse a complete MDX document, extracting frontmatter and content.
32///
33/// This is the main entry point for parsing MDX content. It extracts
34/// YAML frontmatter from the beginning of the document and parses the
35/// remaining content into a tree of `DocNode` elements.
36pub fn parse_document(content: &str) -> ParsedDoc {
37    let (frontmatter, remaining) = extract_frontmatter(content);
38    let nodes = parse_mdx(remaining);
39    let raw_markdown = get_raw_markdown(&nodes);
40
41    ParsedDoc {
42        frontmatter,
43        content: nodes,
44        raw_markdown,
45    }
46}