fix: quote non-ASCII characters in pantry TOML keys#313
Conversation
0eee62e to
78f0881
Compare
78f0881 to
dc43774
Compare
dc43774 to
878f0b5
Compare
878f0b5 to
a7d21f8
Compare
Use cooklang::pantry::to_toml_string() from the parser library (v0.18.4) for all pantry serialization, replacing the hand-rolled TOML string formatting in both src/pantry.rs and src/server/handlers/pantry.rs. The parser library now handles all TOML escaping correctly (including non-ASCII characters like Swedish å, ä, ö), uses inline tables for item attributes, and preserves section/item ordering via IndexMap. Removes toml_edit as a direct CookCLI dependency (now handled by the parser). Uses shift_remove for IndexMap compatibility. Tests added for general items, section/item order preservation, and non-ASCII round-tripping.
a7d21f8 to
e16a503
Compare
Code ReviewThis PR replaces ~120 lines of duplicated hand-rolled TOML serialization across Strengths
Issues
The function is now a one-liner that just calls
Items that were previously serialized as bare strings (
The test confirms that Minor
Overall this is a well-executed fix. The issues above are minor and do not block merging. |
Summary
Fixes #311
cooklang-rs changes (cooklang/cooklang-rs@d12d03c)
pantry::to_toml_string()usingtoml_editfor proper TOML serialization (handles non-ASCII keys, inline tables, general items)PantryConf.sectionschanged fromBTreeMaptoIndexMapto preserve file ordertoml'spreserve_orderfeature so item order within sections is preservedpantry::write()to use the new serializerCookCLI changes
cooklang::pantry::to_toml_string()toml_editas a direct dependency (now handled by the parser library)src/pantry.rsandsrc/server/handlers/pantry.rsshift_removeinstead of deprecatedremovefor IndexMap compatibilityTest plan
test_pantry_general_items_stay_top_level— general items stay at top level, no[general]headertest_pantry_item_order_preserved— item order within sections survives round-triptest_pantry_section_order_preserved— section order survives round-triptest_pantry_non_ascii_round_trip— Swedish characters (smörgås, äpple) round-trip correctly