Skip to main content

parse_item_markdown

Function parse_item_markdown 

Source
pub fn parse_item_markdown(text: &str, path: &Path) -> Result<BacklogItem>
Expand description

Parse a backlog item’s +++ TOML frontmatter and Markdown body.

The parser validates the serialized ItemId, Rank, and required title before returning a domain item. path is included in parse errors so callers can point users to the invalid document.

§Examples

use std::path::Path;
use pinto::storage::parse_item_markdown;

let markdown = "+++\n\
id = \"T-1\"\n\
title = \"Review parser input\"\n\
status = \"todo\"\n\
rank = \"i\"\n\
created = \"1970-01-01T00:00:00Z\"\n\
updated = \"1970-01-01T00:00:00Z\"\n\
+++\n\
body\n";
let item = parse_item_markdown(markdown, Path::new("T-1.md")).expect("valid item");
assert_eq!(item.id.to_string(), "T-1");
assert_eq!(item.body, "body");