Skip to content

API Reference

Exports

ExportTypeDescription
parseCooklang()(source: string) => CooklangRecipeParse a Cooklang string into a structured recipe
grammarOhm.GrammarThe raw Ohm grammar object for advanced use

Types

All types are re-exported and available for import:

ts
import type {
  CooklangRecipe,
  RecipeSection,
  SectionContent,
  RecipeStepItem,
  RecipeIngredient,
  RecipeCookware,
  RecipeTimer,
  ParseError,
  SourcePosition,
} from "cooklang-parse"

See the full Types reference.

Quick Example

ts
import { parseCooklang } from "cooklang-parse"

const recipe = parseCooklang(`Add @flour{250%g} to #bowl.`)

recipe.ingredients  // [{ type: "ingredient", name: "flour", quantity: 250, units: "g", fixed: false }]
recipe.cookware     // [{ type: "cookware", name: "bowl", quantity: 1, units: "" }]

const step = recipe.sections[0].content[0] // { type: "step", items: [...] }
step.items          // [{ type: "text", value: "Add " }, { type: "ingredient", ... }, ...]

Released under the MIT License.