Skip to main content

Crate reget

Crate reget 

Source
Expand description

§Recipe Extraction from HTML documents

reget provides a single function to extract a recipe from HTML documents using structured data (JSON-LD) embedded within.

With the optional markdown feature, recipes can be converted to a markdown string.

This library assumes the document follows the schema.org recipe specification.

§Example

use reget::parse_recipe;

let html = r#"
<!DOCTYPE html>
<html lang="en">
<script type="application/ld+json">
{
  "@type": "Recipe",
  "name": "Delicious Cookies",
  "author": "Lorem Ipsum",
  "recipeIngredient": ["2 cups flour", "1 cup sugar"],
  "recipeInstructions": "Mix ingredients and bake."
}
</script>
</html>
"#;

let recipe = parse_recipe(html).unwrap();

// And with the optional markdown feature    
let md = recipe
    .to_markdown()
    .with_url("https://example.org/recipe")
    .convert();

Structs§

HowToSection
A collection of how-to-steps with an optional name
MarkdownBuilder
A builder to convert the contents of a recipe a markdown string
Recipe
A recipe extracted from HTML using parse_recipe.

Functions§

parse_recipe
Parses the recipe from the given HTML document. Will return None if no linked data is found in the document.

Type Aliases§

HowToStep
A single how-to-step of a recipe
Ingredient
A single ingredient used in a recipe