fix(parser): end a preparation at the end of its line #170

Merged
abiwab merged 1 commit from fix/preparation-single-line into main 2026-11-16 23:50:13 +01:00
Owner

Problem

The preparation rule of grammar.ohm (ingredients, composite parents, cookware) read up to the next ) and never stopped at a line break. One forgotten parenthesis silently swallowed the rest of the recipe:

## A

Mix @flour{200g}(sifted and

Bake at ^{180°C}.

## B

Serve (hot).

The flour got everything up to (hot as its preparation; the bake step, its temperature and section B were gone, with no error and no warning.

Fix

  • preparation = "(" (~(")" | nl) any)* ")": a preparation ends on its line, the same rule as the temperature notes on dev/1.5 (gluedNote). An unclosed parenthesis stays in the text of the step, and what follows is read as usual.
  • A preparation closed on its line reads as before. The only valid input that changes is a preparation spread over two lines of one step, now read as text (said in the changeset).
  • Tests: packages/parser/tests/preparation-single-line.test.ts (ingredient, bare ingredient, cookware, composite parent, closed preparations unchanged).
  • Conformance: new case 048-preparation-single-line. Numbered 048, not 038, because 038 to 047 already exist on dev/1.5.

Checks

  • bun test: 2498 pass, bun run conformance: 107 cases, no existing golden changed; legacy-1.3.0 digests unchanged.
  • bun run lint, typecheck of @gram-lang/parser; audit unchanged (98 flags).
  • Changeset: preparation-single-line.md (@gram-lang/parser, patch).

Merging main into dev/1.5 afterwards

  • packages/parser/src/grammar-content.ts will conflict: it is generated, so take either side and run bun run build to regenerate it from the merged grammar.ohm (which merges cleanly).
  • The two packages/format conflicts from #168 are still to resolve (keep dev/1.5's rules 4 and 4b, rule 5 above them; keep both test blocks).
  • After the merge, preparation and gluedNote have the same body and can become one rule.
## Problem The `preparation` rule of `grammar.ohm` (ingredients, composite parents, cookware) read up to the next `)` and never stopped at a line break. One forgotten parenthesis silently swallowed the rest of the recipe: ```gram ## A Mix @flour{200g}(sifted and Bake at ^{180°C}. ## B Serve (hot). ``` The flour got everything up to `(hot` as its preparation; the bake step, its temperature and section B were gone, with no error and no warning. ## Fix - `preparation = "(" (~(")" | nl) any)* ")"`: a preparation ends on its line, the same rule as the temperature notes on `dev/1.5` (`gluedNote`). An unclosed parenthesis stays in the text of the step, and what follows is read as usual. - A preparation closed on its line reads as before. The only valid input that changes is a preparation spread over two lines of one step, now read as text (said in the changeset). - Tests: `packages/parser/tests/preparation-single-line.test.ts` (ingredient, bare ingredient, cookware, composite parent, closed preparations unchanged). - Conformance: new case `048-preparation-single-line`. Numbered 048, not 038, because 038 to 047 already exist on `dev/1.5`. ## Checks - `bun test`: 2498 pass, `bun run conformance`: 107 cases, no existing golden changed; `legacy-1.3.0` digests unchanged. - `bun run lint`, typecheck of `@gram-lang/parser`; audit unchanged (98 flags). - Changeset: `preparation-single-line.md` (`@gram-lang/parser`, patch). ## Merging `main` into `dev/1.5` afterwards - `packages/parser/src/grammar-content.ts` will conflict: it is generated, so take either side and run `bun run build` to regenerate it from the merged `grammar.ohm` (which merges cleanly). - The two `packages/format` conflicts from #168 are still to resolve (keep `dev/1.5`'s rules 4 and 4b, rule 5 above them; keep both test blocks). - After the merge, `preparation` and `gluedNote` have the same body and can become one rule.
fix(parser): end a preparation at the end of its line
All checks were successful
CI / Build & Test (pull_request) Successful in 3m37s
6620c244d2
abiwab scheduled this pull request to auto merge when all checks succeed 2026-11-16 23:47:39 +01:00
abiwab merged commit 7448a41ce6 into main 2026-11-16 23:50:13 +01:00
abiwab deleted branch fix/preparation-single-line 2026-11-16 23:50:14 +01:00
Sign in to join this conversation.
No description provided.