Crate cooklang

source ·
Expand description

A cooklang parser with opt-in extensions.

The extensions create a superset of the original cooklang language and can be turned off. To see a detailed list go to extensions.

Also includes:

  • Rich error report with annotated code spans.
  • Unit conversion.
  • Recipe scaling.
  • A parser for cooklang aisle configuration file.

§Basic usage

If you just want to parse a single cooklang file, see parse.

If you are going to parse more than one, or want to change the configuration of the parser, construct a parser instance yourself.

To construct a parser use CooklangParser::new or CooklangParser::default if you want to configure the parser. You can configure which Extensions are enabled and the Converter used to convert and check units.

// Create a parser
// (this is the default configuration)
let parser = CooklangParser::new(Extensions::all(), Converter::default());

Then use the parser:

let (recipe, _warnings) = parser.parse("This is an @example").into_result()?;
assert_eq!(recipe.ingredients.len(), 1);
assert_eq!(recipe.ingredients[0].name, "example");

Recipes can be scaled and converted. But the following applies:

Re-exports§

Modules§

Structs§

Functions§

Type Aliases§