Skip to content

Commit bfd4818

Browse files
committed
feat: cookbook creation
1 parent dbfa24a commit bfd4818

1 file changed

Lines changed: 323 additions & 0 deletions

File tree

Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
---
2+
title: "Creating Cookbooks"
3+
description: "Step-by-step guide to transform your Cooklang recipes into professional PDF cookbooks"
4+
date: 2024-01-15
5+
categories:
6+
- Publishing
7+
- Tutorial
8+
tags:
9+
- cookbook
10+
- PDF
11+
- LaTeX
12+
- tutorial
13+
- publishing
14+
featured: true
15+
---
16+
17+
Transform your digital recipe collection into a professional cookbook that you can print, share, or publish. This guide shows you how to use CookCLI's LaTeX export feature (supported in version after 0.18.0) to create PDF cookbooks from your Cooklang recipes.
18+
19+
## 🎯 What You'll Create
20+
21+
By the end of this tutorial, you'll have:
22+
- A professionally formatted PDF cookbook
23+
- Organized chapters by meal type
24+
- Color-coded ingredients and equipment
25+
- Automatic table of contents and index
26+
- Print-ready or digital ebook format
27+
28+
## πŸ“‹ Prerequisites
29+
30+
Before starting, make sure you have:
31+
32+
1. **CookCLI installed** ([Installation guide](/cli/download))
33+
2. **LaTeX distribution** installed:
34+
```bash
35+
# macOS
36+
brew install --cask mactex
37+
38+
# Ubuntu/Debian
39+
sudo apt-get install texlive-full
40+
41+
# Windows
42+
# Download MiKTeX from https://miktex.org/
43+
```
44+
3. **Your recipes** in `.cook` format organised in folders (that will become book chapters later)
45+
46+
```
47+
my_recipes/
48+
β”œβ”€β”€ breakfast/
49+
β”‚ └── pancakes.cook
50+
β”œβ”€β”€ lunch/
51+
β”‚ └── sandwich.cook
52+
└── dinner/
53+
└── pasta.cook
54+
```
55+
56+
## πŸš€ Quick Start: Your First Cookbook in 5 Minutes
57+
58+
### Step 1: Get the Cookbook Tools
59+
60+
```bash
61+
# Clone the cookbook creator repository
62+
git clone https://github.com/cooklang/cookbook-creator.git
63+
cd cookbook-creator
64+
65+
# Or download just the script
66+
wget https://raw.githubusercontent.com/cooklang/cookbook-creator/main/scripts/create_cookbook.py
67+
```
68+
69+
### Step 2: Generate Your Cookbook
70+
71+
```bash
72+
# Generate cookbook LaTeX file from your recipes directory
73+
python3 scripts/create_cookbook.py path/to/recipes my_cookbook.tex \
74+
--title "Family Recipes" \
75+
--author "Your Name"
76+
77+
# Or try with the included example recipes
78+
python3 scripts/create_cookbook.py examples/recipes my_cookbook.tex \
79+
--title "Sample Cookbook" \
80+
--author "Jane Doe"
81+
```
82+
83+
### Step 3: Compile to PDF
84+
85+
```bash
86+
# Compile the LaTeX file to PDF
87+
pdflatex my_cookbook.tex
88+
makeindex my_cookbook.idx # Generate index
89+
pdflatex my_cookbook.tex # Update references
90+
pdflatex my_cookbook.tex # Final compilation
91+
92+
# Open your new cookbook!
93+
open my_cookbook.pdf # macOS
94+
xdg-open my_cookbook.pdf # Linux
95+
```
96+
97+
## πŸ“– Step-by-Step Walkthrough
98+
99+
### 1️⃣ Organize Your Recipes
100+
101+
Structure your recipes in folders by category:
102+
103+
```
104+
my-recipes/
105+
β”œβ”€β”€ breakfast/
106+
β”‚ β”œβ”€β”€ pancakes.cook
107+
β”‚ β”œβ”€β”€ french-toast.cook
108+
β”‚ └── smoothie-bowl.cook
109+
β”œβ”€β”€ lunch/
110+
β”‚ β”œβ”€β”€ caesar-salad.cook
111+
β”‚ └── grilled-cheese.cook
112+
β”œβ”€β”€ dinner/
113+
β”‚ β”œβ”€β”€ roast-chicken.cook
114+
β”‚ β”œβ”€β”€ pasta-carbonara.cook
115+
β”‚ └── vegetable-stir-fry.cook
116+
└── desserts/
117+
β”œβ”€β”€ chocolate-cake.cook
118+
└── apple-pie.cook
119+
```
120+
121+
The folder names become chapter titles in your cookbook!
122+
123+
### 2️⃣ Generate Your Cookbook
124+
125+
#### Using the Python Script (Recommended)
126+
127+
```bash
128+
cd cookbook-creator
129+
python3 scripts/create_cookbook.py ~/my-recipes my-cookbook.tex \
130+
--title "The Smith Family Cookbook" \
131+
--author "Jane Smith"
132+
```
133+
134+
#### Script Options
135+
136+
```bash
137+
# Basic usage
138+
python3 scripts/create_cookbook.py <recipe_directory> <output_file> [options]
139+
140+
# Available options:
141+
--title TITLE # Cookbook title (default: "My Cookbook")
142+
--author AUTHOR # Author name (optional)
143+
--no-index # Skip index generation
144+
--no-toc # Skip table of contents
145+
```
146+
147+
#### Manual Generation
148+
149+
For individual recipes, you can use CookCLI directly:
150+
151+
```bash
152+
# Generate LaTeX for a single recipe
153+
cook recipe -f latex "breakfast/pancakes.cook" > pancakes.tex
154+
```
155+
156+
### 3️⃣ Customize Your Cookbook
157+
158+
Edit the generated `.tex` file to customize:
159+
160+
```latex
161+
% Change colors
162+
\definecolor{ingredientcolor}{RGB}{219, 112, 147} % Pink
163+
\definecolor{cookwarecolor}{RGB}{100, 149, 237} % Blue
164+
\definecolor{timercolor}{RGB}{255, 140, 0} % Orange
165+
166+
% Add dedication
167+
\chapter*{Dedication}
168+
To my grandmother, who taught me that cooking is love...
169+
170+
% Add introduction to chapters
171+
\chapter{Breakfast}
172+
\section*{Introduction}
173+
These breakfast recipes have been weekend favorites...
174+
```
175+
176+
### 4️⃣ Add Special Sections
177+
178+
```latex
179+
% Add conversion tables
180+
\chapter*{Conversion Tables}
181+
\begin{tabular}{ll}
182+
\toprule
183+
US & Metric \\
184+
\midrule
185+
1 cup & 240 ml \\
186+
1 tbsp & 15 ml \\
187+
\bottomrule
188+
\end{tabular}
189+
190+
% Add tips section
191+
\chapter*{Kitchen Tips}
192+
\begin{itemize}
193+
\item Always preheat your oven
194+
\item Mise en place is key
195+
\item Season as you go
196+
\end{itemize}
197+
```
198+
199+
## πŸ› οΈ Advanced Features
200+
201+
### Including Recipe Images
202+
203+
The script automatically finds and includes images that match your recipe names:
204+
205+
```
206+
recipes/
207+
β”œβ”€β”€ pasta-carbonara.cook
208+
β”œβ”€β”€ pasta-carbonara.jpg # Will be automatically included
209+
β”œβ”€β”€ chocolate-cake.cook
210+
└── chocolate-cake.png # Will be automatically included
211+
```
212+
213+
Supported image formats: PNG, JPG, JPEG
214+
215+
### Creating Multiple Versions
216+
217+
```bash
218+
# Family version with all recipes
219+
python3 create_cookbook.py recipes family-cookbook.tex
220+
221+
# Gift version with selected recipes
222+
python3 create_cookbook.py recipes/favorites gift-cookbook.tex \
223+
--title "Our Favorite Recipes for You"
224+
```
225+
226+
### Customizing Colors
227+
228+
Edit the generated LaTeX file to change ingredient, cookware, and timer colors:
229+
230+
```latex
231+
% Color definitions (RGB values)
232+
\definecolor{ingredientcolor}{RGB}{204, 85, 0} % Orange
233+
\definecolor{cookwarecolor}{RGB}{34, 139, 34} % Green
234+
\definecolor{timercolor}{RGB}{220, 20, 60} % Red
235+
```
236+
237+
### Scaling Recipes
238+
239+
```bash
240+
# Generate scaled versions for different serving sizes
241+
cook recipe -f latex "dinner/lasagna.cook:12" > lasagna-party.tex
242+
```
243+
244+
### Download Sample Cookbook
245+
246+
[Download a sample PDF cookbook](https://github.com/cooklang/cookbook-creator/blob/main/examples/my_cookbook.pdf) to see what you can create!
247+
248+
## πŸ’‘ Pro Tips
249+
250+
### 1. Recipe Metadata
251+
The script extracts metadata from recipe comments. Add metadata to your `.cook` files:
252+
253+
```cooklang
254+
---
255+
description: A classic Italian pasta dish
256+
tags: italian, pasta, quick
257+
servings: 4
258+
prep time: 15 minutes
259+
cook time: 20 minutes
260+
---
261+
```
262+
263+
### 2. Organizing by Chapters
264+
The script automatically creates chapters based on your directory structure:
265+
266+
```
267+
recipes/
268+
β”œβ”€β”€ appetizers/ β†’ Chapter: Appetizers
269+
β”œβ”€β”€ main-dishes/ β†’ Chapter: Main Dishes
270+
β”œβ”€β”€ desserts/ β†’ Chapter: Desserts
271+
└── beverages/ β†’ Chapter: Beverages
272+
```
273+
274+
### 3. Recipe Index
275+
The script automatically generates:
276+
- Recipe index by name
277+
- Index by tags (if metadata includes tags)
278+
- Index by author (if metadata includes author)
279+
280+
### 4. Version Control
281+
Keep your recipes and cookbook under version control:
282+
283+
```bash
284+
git init my-cookbook
285+
git add *.cook *.tex scripts/
286+
git commit -m "Initial cookbook version"
287+
```
288+
289+
290+
## 🚧 Troubleshooting
291+
292+
### Common Issues and Solutions
293+
294+
| Problem | Solution |
295+
|---------|----------|
296+
| "LaTeX command not found" | Install TeX distribution for your OS |
297+
| "Package not found" error | Run `tlmgr install enumitem multicol xcolor titlesec geometry hyperref makeidx imakeidx fancyhdr` |
298+
| "cook command not found" | Install CookCLI or use `cargo run` if building from source |
299+
| Missing colors in PDF | Ensure `xcolor` package is included |
300+
| Index not generated | Run `makeindex` between compilations |
301+
| Recipes not found | Check file extensions are `.cook` |
302+
| Images not showing | Ensure image files match recipe names (e.g., `pasta.cook` β†’ `pasta.jpg`) |
303+
304+
## πŸ“š Resources
305+
306+
- πŸ“– [Cookbook Creator repository](https://github.com/cooklang/cookbook-creator)
307+
- πŸ“ [CookCLI documentation](/cli/)
308+
- πŸ“„ [Example PDF cookbook](https://github.com/cooklang/cookbook-creator/blob/main/examples/my_cookbook.pdf)
309+
- πŸ’¬ [Community forum](https://github.com/cooklang/spec/discussions)
310+
311+
## πŸŽ‰ Share Your Creation
312+
313+
Created a beautiful cookbook? We'd love to see it!
314+
315+
- Share on social media with **#CooklangCookbook**
316+
- Post in our [community forum](https://github.com/cooklang/spec/discussions)
317+
- Submit your template to the cookbook-sample repository
318+
319+
---
320+
321+
**Ready to create your cookbook?** [Get started with the cookbook-creator toolkit β†’](https://github.com/cooklang/cookbook-creator)
322+
323+
*Transform your recipes into a beautiful cookbook today with CookCLI!*

0 commit comments

Comments
Β (0)