Skip to main content

extract_metadata_with_limits

Function extract_metadata_with_limits 

Source
pub fn extract_metadata_with_limits(
    content: &str,
    limits: &ParseLimits,
) -> Result<Metadata, MetadataError>
Expand description

Extracts metadata like extract_metadata, under explicit ParseLimits.

§Errors

Returns MetadataError::ExtractionError when no front matter is found, the block exceeds limits.max_block_bytes, or an opening fence has no closing fence (the message carries the byte offset); MetadataError::Parse when a parser rejects the block; and MetadataError::UnsupportedFormatError when the block’s format was not compiled in.

§Example

use metadata_gen::{extract_metadata_with_limits, ParseLimits};

let doc = "---\ntitle: Limits\n---\n";
let metadata = extract_metadata_with_limits(doc, &ParseLimits::default()).unwrap();
assert_eq!(metadata.get("title").unwrap(), "Limits");