Feature: Nutritional and caloric calculation (per 100g / per serving) #5

Open
opened 2026-07-17 22:58:46 +02:00 by abiwab · 0 comments
abiwab commented 2026-07-17 22:58:46 +02:00 (Migrated from codeberg.org)

Context

Gram already supports calculating nutritional information for the entire recipe as a whole. This is however insufficient for practical, everyday use.

Goal

The goal is to introduce a way to display these nutritional calculations in more standardized units, specifically per 100 grams or per defined portions.

Technical Challenges & architecture

  • Defining the Serving Size: The most obvious approach is to use the portions: field in the frontmatter. However, should a fallback mechanism be designed for recipes where this field is omitted ?
  • Separation of Concerns: It needs to be determined where these calculations should occur. Should the analyzer compute the per-100g and per-serving values and attach them to the AST, or should the analyzer only provide the total nutritional data, leaving the renderer responsible for deriving the specific serving/100g metrics? The responsibility boundaries between the core engine and the UI layer must be clearly defined.
### Context Gram already supports calculating nutritional information for the entire recipe as a whole. This is however insufficient for practical, everyday use. ### Goal The goal is to introduce a way to display these nutritional calculations in more standardized units, specifically per 100 grams or per defined portions. ### Technical Challenges & architecture - **Defining the Serving Size:** The most obvious approach is to use the portions: field in the frontmatter. However, should a fallback mechanism be designed for recipes where this field is omitted ? - **Separation of Concerns:** It needs to be determined where these calculations should occur. Should the analyzer compute the per-100g and per-serving values and attach them to the AST, or should the analyzer only provide the total nutritional data, leaving the renderer responsible for deriving the specific serving/100g metrics? The responsibility boundaries between the core engine and the UI layer must be clearly defined.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gram-lang/gram#5
No description provided.