Skip to content

Commit 64adfe4

Browse files
authored
fix: remove 'some' prefix from RenderDisplay for unspecified quantities (#9)
When an ingredient has no quantity specified (e.g., @olive{}), RenderDisplay() was outputting 'some olive' instead of just 'olive'. This caused awkward prose like 'use an some olive'. The 'some' prefix is not part of the cooklang spec - ingredients without quantities should just display their name. This aligns with the spec's example: 'Then add @salt and @Ground black pepper{} to taste.'
1 parent 1bc6ea8 commit 64adfe4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cooklang.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ func (i Ingredient) Render() string {
237237
}
238238

239239
// RenderDisplay returns ingredient in plain text format suitable for display.
240-
// Examples: "2 cups flour", "500 g flour", "some salt", "flour"
240+
// Examples: "2 cups flour", "500 g flour", "salt"
241241
// Uses bartender-friendly fraction formatting (e.g., "1/2 oz" instead of "0.5 oz")
242+
// When quantity is unspecified (e.g., @salt{}), returns just the ingredient name.
242243
func (i Ingredient) RenderDisplay() string {
243244
var result string
244245
if i.Quantity > 0 && i.Unit != "" {
@@ -247,9 +248,8 @@ func (i Ingredient) RenderDisplay() string {
247248
} else if i.Quantity > 0 {
248249
qtyStr := FormatAsFractionDefault(float64(i.Quantity))
249250
result = fmt.Sprintf("%s %s", qtyStr, i.Name)
250-
} else if i.Quantity == -1 {
251-
result = fmt.Sprintf("some %s", i.Name)
252251
} else {
252+
// Quantity == -1 (unspecified) or 0: just use the ingredient name
253253
result = i.Name
254254
}
255255
return result

0 commit comments

Comments
 (0)