Repository navigation
fix(format): re-emit the = scaling lock in cooklang source - #737
Conversation
`ComponentFormatter` never wrote `=`, so `@egg{=2}` round-tripped as
`@egg{2}` and the quantity silently became scalable — scaling the
formatted recipe ×10 gives 20 eggs instead of 2. Emit the lock for
ingredient quantities that parsed as non-scalable; cookware, timers and
text values can't carry it without a parser warning.
Closes #702
b8b9fcf to
0e9d046
Compare
LeMyst
left a comment
There was a problem hiding this comment.
Looks good to me. scalable == false on a non-text ingredient quantity can only come from a lock. Cookware and timers are never scaled, so leaving the lock off them loses nothing. A locked fraction now round-trips as @egg{=1/2%cup}.
- The re-emitted lock makes the parser warn "Unnecessary scaling lock modifier" on parse-back, but that's a cooklang-rs bug: it warns on every lock, even a valid
@egg{=2}. It isn't caused by this PR, and it may deserve an issue there. - Optional test: format at scale ×10 and check that
{=2}is still there.
This conflicts with #736 in the if let Some(q) block (push =, then write_value) and in the tests, and with #735 in the tests. Also note that #755 currently refuses locked fractions, which this PR makes round-trip.
🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst.
|
Added the ×10 test ( |
57d96fc to
6acedad
Compare
|
Thanks. For whoever merges second, there are two small conflicts in
🤖 Analysis and recommendations made by Claude (Anthropic's AI assistant), posted on behalf of @LeMyst. |
Resolves the conflict with #736 in crates/format/src/cooklang_source.rs: write this PR's `=` lock first, then the value through #736's write_value, and keep both PRs' tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GYHHHngC4XZ4nfdgP4p3Pe
Closes #702
ComponentFormatternever wrote=, so@egg{=2}round-tripped as@egg{2}and reparsed withscalable: true— scaling the formatted recipe ×10 gives 20 eggs instead of 2. The lock is now emitted for ingredient quantities that parsed non-scalable; cookware, timers and text values can't carry it without a parser warning, so those are left alone.Test plan
a_locked_quantity_keeps_its_lockasserts the marker survives and reparse givesscalable: falsecargo test -p cooklang-formatgreenAdd @egg{=2} and @milk{100%ml}.round-trips verbatim