html_generator::utils

Function extract_front_matter

Source
pub fn extract_front_matter(content: &str) -> Result<String>
Expand description

Extracts front matter from Markdown content.

§Arguments

  • content - A string slice that holds the content to process.

§Returns

  • Result<String> - The content with front matter removed, or an error.

§Errors

This function will return an error if:

  • The input is empty or exceeds the maximum allowed size.
  • The front matter is invalidly formatted.

§Examples

use html_generator::utils::extract_front_matter;

let content = "---\ntitle: My Page\n---\n# Hello, world!\n\nThis is a test.";
let result = extract_front_matter(content).unwrap();
assert_eq!(result, "# Hello, world!\n\nThis is a test.");