- TypeScript 68%
- MDX 22%
- Vue 3.6%
- CSS 2.8%
- Astro 2.7%
- Other 0.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| data | ||
| docs | ||
| examples | ||
| packages | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| deploy.sh | ||
| gram-banner.png | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.base.json | ||
GRAM - General Recipe Abstract Markup
A strictly typed, data-first recipe markup language for developers.
GRAM is designed to write structured, machine-readable recipes without sacrificing readability. It treats recipes as code, compiling ingredients, instructions, and cookware into a strict AST (Abstract Syntax Tree) for precise analysis, scaling, and shopping list generation.
👉 Try the Online Playground (or run it locally)
🚧 Project Status: Active Development GRAM is currently in an Alpha stage. The syntax specification is stabilizing, but the parser logic is actively being refined. Breaking changes may occur. This is an Open Source project. We believe standardizing recipe data requires a community effort. Feedback, feature requests, and code contributions are highly welcome!
Please see CONTRIBUTING.md for more information on how to contribute to GRAM.
📚 Documentation
The full technical documentation is available in the docs/ folder.
🥘 Why GRAM?
Inspired by the excellent Cooklang, GRAM evolves the concept by enforcing a strict schema and advanced logic capabilities.
While Cooklang focuses on natural language fluidity, GRAM prioritizes data integrity and computational logic:
- Data vs. Narrative: Clear separation between ingredients (
@flour{200g}) and instructions. - Mise en Place: Distinguishes between the Shopping List (Aggregated totals) and the Section List (What you need on the table right now).
- Advanced Syntax Features:
- Actions (
[Mix]): Highlights the main method used in a step - References (
@&): Reuse previously measured ingredients without doubling the shopping list amount. - Intermediate Preparations (
->&dough): Chain recipe parts like variables. - Relative Quantities: Define
@water{60% @flour}for dynamic bakers math. - Composites: Handle "Zest of 1 lemon" and "Juice of 2 lemon" implying "Buy 2 Lemon".
- Actions (
- Automated Insights:
- Mass Unification: Automatically converts volumes and units to grams (e.g.,
1 cup flour->125g). - Yield Management: Understands that buying
1 avocadoresults in~135gof edible flesh (Purchasing vs. Net Mass). - Nutritional Estimation: Automatically calculates calories and macros based on an integrated ingredient database (POC).
- Scheduling: Distinguishes Active Time (labor), Prep Time (mise en place) and Cook Time (actual cooking) from Total Time (including background tasks like rising or marinating).
- Mass Unification: Automatically converts volumes and units to grams (e.g.,
→ See the full feature list for more details.
⚡ Quick Syntax
## Dough {T-2h}
[Mix] The @flour{200g} and @water{100ml}. ->&dough{}
[Add] The &dough{} to a #bowl{}.
[Rest] For ~{30min}.
[Bake] In the #oven{} at !{200°C}.
You can find more real-world examples in the examples/ directory at the root of the project.
🛠️ Project Structure
This monorepo contains the following packages in packages/:
parser/: The core parser. Converts GRAM strings to an AST (Abstract Syntax Tree).compiler/: The compiler logic. Transforms the AST into the final Shopping List and Instructions JSON.playground/: A web-based IDE to write GRAM and visualize the output (JSON, Markdown, Preview).
And:
vscode-extension/: The Visual Studio Code extension (located inpackages/vscode-extension/).
🤝 Contributing
We need your help to make GRAM the standard for structured recipes!
Whether you are a developer, a chef, or a data enthusiast, your contributions are welcome.
- Found a bug? Open an issue to help us squash it.
- Have an idea? Start a discussion on syntax improvements.
- Want to code? Fork the repo and submit a Pull Request.
📦 Try it out
1. Run the Playground locally
To inspect the parser or test your recipes in the web-based playground IDE:
# Install dependencies for all packages
npm install
# Build parser, compiler, and playground
npm run build
# Run the playground
npm run dev
2. Use the Parser
(See parser/README.md for API details)
const { getAST } = require('gram-parser');
const { compile } = require('gram-compiler');
const ast = getAST(myGramString);
const result = compile(ast);
console.log(result.shopping_list);
👏 Acknowledgments
GRAM stands on the shoulders of giants.
- Cooklang: For pioneering the concept of a recipe markup language. GRAM was heavily inspired by their concise syntax.
- Ohm.js: For making parsing accessible and robust.
- LLM Assistance: This project was developed with the assistance of AI for rapid prototyping, refactoring, and generating test cases. All logic and architecture were strictly verified by humans.
License
Distributed under the GPL-3.0 License.
