Repository navigation
feat: range quantities scale and add up (cooklang 0.23.0, spec 0011) - #865
Merged
Merged
Conversation
Bump cooklang and cooklang-ingredient-parser to 0.23.0, cooklang-reports to 0.11.0 and cooklang-language-server to 0.7.0. cooklang 0.23 parses ranges without extensions, so @Garlic{2-3%cloves} is a range rather than text to CookCLI's parser: it scales (#597), adds up on shopping lists and in reports, and is a range in JSON. - doctor: drop the RANGE_VALUES workaround in the timer pass - a zero denominator in a range ({1-1/0}) is an error, per the spec - schema.org: a range timer gives timeRequired (its average) - fix stale comments about range values and cooklang-reports' parser - tests: range scaling, JSON and shopping list totals; the BOM span test no longer relies on the dropped scaling-lock warning Fixes #597. Part of #862.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bumps cooklang to 0.23.0, cooklang-ingredient-parser to 0.23.0, cooklang-reports to 0.11.0 and cooklang-language-server to 0.7.0.
cooklang 0.23 makes ranges core syntax (spec proposal 0011). CookCLI's parser has no extensions, so until now
@garlic{2-3%cloves}wasText("2-3"). With this bump it is a range everywhere.Fixes #597. Part of #862: the first item, plus what the bump changes in tests and comments.
What changes for users
Checked by hand with the released
cook0.41.1 and this branch, on@garlic{2-3%cloves},@chilli flakes{1/2-1%tsp},~{25-30%minutes}and@salt{1%tsp}plus@salt{1-2%tsp}:recipe read -f cooklang range.cook:2on@flour{1-2%tbsp}(#597)@flour{1-2%tbsp}@flour{2-4%tbsp}recipe read, salt1 tsp, 1-2 tsp2 - 3 tsprecipe read …:4, garlic2-3 cloves8 - 12 clovesshopping-list, salt1 tsp, 1-2 tsp2 - 3 tspreportwithget_ingredient_list, two@saffron{0.3335%g}0.668 g0.667 g{"type":"text","value":"2-3"}{"type":"range","value":{"start":…,"end":…}}~{10-20%minutes}timeRequiredPT15M(the average, asschema.rsalready did for scaled ranges)@beans{1-1/0%cans}The web recipe page and shopping list render ranges (
2 - 3 cloves,⏱️ 25 - 30 minutes). The shopping list JS already handledtype: "range".Visible side effects:
2 - 3, where the text used to show2-3.0.5-1 tsp, as1/2 cupalready showed as0.5 cupthere.Picking one display separator is item 3 of #862.
Code changes
doctor: the timer pass no longer addsExtensions::RANGE_VALUES, which does nothing from cooklang 0.23. The comments that explained it are updated.report.rssaid cooklang-reports parses with every extension on, but it uses none;schema.rssaid ranges only come from scaling;cooklang_source.rsmentionedRANGE_VALUES.Tests
tests/ranges_test.rs:-f cooklang;doctor:@beans{1-1/0%cans}is now one error, on the beans.@flour{1/0 cups}is still text.schema_output_test: the text-timer test uses~{a few%minutes}, and a new test pinsPT15Mfor~{10-20%minutes}.parser: the BOM span test used the "Unnecessary scaling lock modifier" warning on@salt{=1}. cooklang 0.23 drops that warning (fix: no warning for a scaling lock on a numeric ingredient cooklang-rs#163), so the test uses a unit-less timer's warning.Not in this PR (rest of #862)
These are unchanged by the bump. Each behaves as it did when ranges were text:
One write path does change: new
.shopping-listselection lines (optional_selections, written withDisplay).@?chilli flakes{1/3-1/2%tsp}gives0.333-0.5%tspat ×1 and0.667-1%tspat ×2.1/3-1/2%tsp, at every scale.@?pepper{1/3%tsp}gives0.333%tsp.Quantity::to_cooklang.Quantity::to_cooklangas well (Range quantities: scale, add up and time {2-3%cloves} and ~{25-30%minutes} as numbers (spec 0011) #862 item 8).The schema.org lower-end-or-average decision (item 5) is also open. This PR keeps the average.