@@ -217,6 +217,8 @@ func (Instruction) isStepComponent() {}
217217func (Timer ) isStepComponent () {}
218218func (Cookware ) isStepComponent () {}
219219func (Ingredient ) isStepComponent () {}
220+ func (Section ) isStepComponent () {}
221+ func (Comment ) isStepComponent () {}
220222
221223// Render returns the Cooklang syntax representation of this ingredient.
222224// Examples: "@flour{500%g}", "@salt{}", "@milk{2%cups}(cold)"
@@ -319,6 +321,34 @@ func (c Cookware) RenderDisplay() string {
319321 return c .Name
320322}
321323
324+ // Render returns the Cooklang syntax representation of this section.
325+ // Examples: "== Section Name =="
326+ func (s Section ) Render () string {
327+ if s .Name != "" {
328+ return fmt .Sprintf ("== %s ==" , s .Name )
329+ }
330+ return "=="
331+ }
332+
333+ // RenderDisplay returns section name suitable for display.
334+ func (s Section ) RenderDisplay () string {
335+ return s .Name
336+ }
337+
338+ // Render returns the Cooklang syntax representation of this comment.
339+ // Examples: "-- comment text" for line comments, "[- comment text -]" for block comments
340+ func (cm Comment ) Render () string {
341+ if cm .IsBlock {
342+ return fmt .Sprintf ("[- %s -]" , cm .Text )
343+ }
344+ return fmt .Sprintf ("-- %s" , cm .Text )
345+ }
346+
347+ // RenderDisplay returns comment text suitable for display.
348+ func (cm Comment ) RenderDisplay () string {
349+ return cm .Text
350+ }
351+
322352// Ingredient represents a recipe ingredient with quantity, unit, and optional annotations.
323353// Ingredients support unit conversion and consolidation for shopping lists.
324354//
@@ -392,6 +422,29 @@ type Cookware struct {
392422 CooklangRenderable
393423}
394424
425+ // Section represents a section header in a recipe.
426+ // Sections divide complex recipes into logical parts (e.g., "Dough", "Filling").
427+ //
428+ // Example Cooklang syntax: = Dough, == Filling ==
429+ type Section struct {
430+ Name string `json:"name,omitempty"` // Section name (e.g., "Dough", "Filling")
431+ NextComponent StepComponent `json:"next_component,omitempty"` // Next component in the step
432+ CooklangRenderable
433+ }
434+
435+ // Comment represents a comment in a recipe.
436+ // Comments are notes that don't affect the cooking instructions.
437+ //
438+ // Example Cooklang syntax:
439+ // - Line comment: -- This is a comment
440+ // - Block comment: [- This is a block comment -]
441+ type Comment struct {
442+ Text string `json:"text,omitempty"` // Comment text
443+ IsBlock bool `json:"is_block,omitempty"` // True if this is a block comment [- -]
444+ NextComponent StepComponent `json:"next_component,omitempty"` // Next component in the step
445+ CooklangRenderable
446+ }
447+
395448// ParseFile reads and parses a Cooklang recipe file, returning a Recipe object.
396449// It automatically detects and includes associated image files matching the recipe filename.
397450//
@@ -692,6 +745,20 @@ func ToCooklangRecipe(pRecipe *parser.Recipe) *Recipe {
692745 stepComp = & Instruction {
693746 Text : component .Value ,
694747 }
748+ case "section" :
749+ stepComp = & Section {
750+ Name : component .Name ,
751+ }
752+ case "comment" :
753+ stepComp = & Comment {
754+ Text : component .Value ,
755+ IsBlock : false ,
756+ }
757+ case "blockComment" :
758+ stepComp = & Comment {
759+ Text : component .Value ,
760+ IsBlock : true ,
761+ }
695762 }
696763
697764 if stepComp != nil {
@@ -959,6 +1026,24 @@ func (c *Cookware) GetNext() StepComponent {
9591026 return c .NextComponent
9601027}
9611028
1029+ // SetNext and GetNext methods for Section
1030+ func (s * Section ) SetNext (next StepComponent ) {
1031+ s .NextComponent = next
1032+ }
1033+
1034+ func (s * Section ) GetNext () StepComponent {
1035+ return s .NextComponent
1036+ }
1037+
1038+ // SetNext and GetNext methods for Comment
1039+ func (cm * Comment ) SetNext (next StepComponent ) {
1040+ cm .NextComponent = next
1041+ }
1042+
1043+ func (cm * Comment ) GetNext () StepComponent {
1044+ return cm .NextComponent
1045+ }
1046+
9621047// IngredientList represents a collection of ingredients with unit consolidation capabilities.
9631048// It provides methods for grouping, converting, and consolidating ingredients for shopping lists
9641049// and recipe scaling operations.
0 commit comments