Skip to main content

compile_markdown

Function compile_markdown 

Source
pub fn compile_markdown(
    page: UncompiledPage,
    registry: &ComponentRegistry,
) -> Result<CompiledPage, PageError>
Expand description

Converts an UncompiledPage into a CompiledPage HTML fragment.

JSX-style component tags are expanded before Markdown parsing.

ยงExamples

use orbit_md::components::ComponentRegistry;
use orbit_md::config::Config;
use orbit_md::models::{FrontMatter, SourcePage, UncompiledPage};
use orbit_md::parser::compile_markdown;
use std::path::PathBuf;

let registry = ComponentRegistry::from_config(&Config::default()).unwrap();
let page = UncompiledPage::new(SourcePage {
    source_path: PathBuf::from("content/post.md"),
    relative_path: PathBuf::from("post.md"),
    front_matter: FrontMatter::default(),
    body: "# Hello".to_owned(),
});

let compiled = compile_markdown(page, &registry).unwrap();
assert!(compiled.content_html.contains("<h1>"));