Crate recipemd

Source
Expand description

A library for parsing recipes written in markdown that follows the RecipeMD specification.

§Example

const MARKDOWN: &str = r#"# Water

A refreshing drink that should be consumed several times a day.

*drink, non-alcoholic, H2O*

**1 glass**

---

- *1* glass
- *1* faucet

---

Turn on the faucet and fill the glass.
"#;

let recipe = Recipe::parse(MARKDOWN)?;
println!("{recipe:#?}");
Result of the above program
Recipe {
    title: "Water",
    description: Some(
        "A refreshing drink that should be consumed several times a day.",
    ),
    tags: [
        "drink",
        "non-alcoholic",
        "H2O",
    ],
    yields: [
        Amount {
            factor: Integer(
                1,
            ),
            unit: Some(
                "glass",
            ),
        },
    ],
    ingredients: [
        Ingredient {
            amount: Some(
                Amount {
                    factor: Integer(
                        1,
                    ),
                    unit: None,
                },
            ),
            name: "glass",
            link: None,
        },
        Ingredient {
            amount: Some(
                Amount {
                    factor: Integer(
                        1,
                    ),
                    unit: None,
                },
            ),
            name: "faucet",
            link: None,
        },
    ],
    ingredient_groups: [],
    instructions: Some(
        "Turn on the faucet and fill the glass.",
    ),
}

(If it doesn’t show up, visit the docs instead)

Structs§

Amount
An Amount used for ingredients and yields.
Error
Returned if a parsing a recipe was not successful.
Ingredient
An Ingredient.
IngredientGroup
An IngredientGroup.
Recipe
A Recipe as defined by the RecipeMD specification.

Enums§

ErrorKind
The exact reason why parsing of the recipe failed.
Factor
Represents the numerical part of an Amount.

Type Aliases§

Result
Type alias for Result<T, recipemd::Error>.