Files
yq/pkg/yqlib
CopilotGitHubmikefarahcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2927a28283 TOML encoder: prefer readable table sections over inline tables (#2649)
* Initial plan

* Fix TOML encoder to prefer readable table sections over inline tables

When converting from YAML/JSON to TOML, the encoder now always uses
readable TOML table section syntax ([section]) instead of compact inline
hash table syntax (key = { ... }), which better matches TOML's goal as
a human-focused configuration format.

Changes:
- decoder_toml.go: Mark inline TOML tables with FlowStyle so round-trips
  can be distinguished from YAML flow mappings
- encoder_toml.go:
  - encodeTopLevelEntry: use FlowStyle check instead of EncodeSeparate to
    decide inline vs table section (all block mappings now become tables)
  - encodeSeparateMapping: count FlowStyle children as attributes; use
    recursive encodeSeparateMapping for nested non-flow mappings
  - encodeMappingBodyWithPath: emit non-flow child mappings as sub-table
    sections instead of inline tables
- toml_test.go: add encode (YAML→TOML) test scenarios, update roundtrip
  expectations for inline tables (now expanded to table sections)

Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/4824a219-6d5e-42e7-bca1-a8a277bf8c6a

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>

* Fix TOML roundtrip: use TomlInline flag instead of FlowStyle to preserve inline tables

FlowStyle affected YAML decode output (causing inline tables to appear as
YAML flow mappings). Replace it with a new TOML-specific TomlInline bool
on CandidateNode that:
- Is set by the TOML decoder for inline tables (not FlowStyle)
- Is copied by UpdateAttributesFrom so it survives DeeplyAssign merges
- Is checked by the TOML encoder alongside FlowStyle (for YAML flow maps)
- Has no effect on the YAML encoder, preserving existing TOML→YAML output

TOML roundtrip tests are restored to their original expected values (inline
tables stay inline, table sections stay as sections).

Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/f59bdf62-6d16-4664-991b-38eb87c9d81c

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>

* Refactor EncodeSeparate+TomlInline into a single EncodeHint enum

Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/24db9a8f-601d-4ccf-ada7-129ed3226bb6

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>

* Fix stale comment in hasStructuralChildren

Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/24db9a8f-601d-4ccf-ada7-129ed3226bb6

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>

* Remove unused hasStructuralChildren method from tomlEncoder

Agent-Logs-Url: https://github.com/mikefarah/yq/sessions/2c234b77-28e9-4995-ba6f-9d213ec551a0

Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>
2026-04-12 18:36:43 +10:00
..
2023-10-18 12:11:53 +11:00
2025-12-20 19:11:48 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2026-02-01 10:27:18 +11:00
2025-12-20 19:11:48 +11:00
2025-05-17 18:55:53 +10:00
2024-02-24 15:48:59 +11:00
2025-05-03 16:34:21 +10:00
2025-06-07 15:23:38 +10:00
2026-02-01 10:27:18 +11:00
2025-12-08 20:30:47 +11:00
2025-05-17 18:55:53 +10:00
2025-05-17 18:55:53 +10:00
2024-02-24 15:59:12 +11:00
2026-04-06 19:29:07 +10:00
2024-02-24 15:36:16 +11:00
2023-10-18 12:11:53 +11:00
2025-12-08 20:30:47 +11:00
2023-10-03 16:22:23 +11:00
2025-12-26 11:08:24 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2023-10-18 12:11:53 +11:00
2024-11-16 11:48:53 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2025-11-09 16:12:17 +11:00
2025-11-09 16:12:17 +11:00
2023-10-18 12:11:53 +11:00
2023-10-02 14:43:12 +11:00
2024-01-11 13:17:34 +11:00
2023-03-16 13:39:36 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2025-05-03 16:34:21 +10:00
2025-05-03 16:34:21 +10:00
2025-05-03 16:34:21 +10:00
2023-10-18 12:11:53 +11:00
2024-03-30 13:29:35 +11:00
2024-01-11 13:17:34 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2025-06-07 15:23:38 +10:00
2023-10-18 12:11:53 +11:00
2024-01-11 13:17:34 +11:00
2023-10-18 12:11:53 +11:00
2025-06-07 15:23:38 +10:00
2024-06-15 17:06:17 +10:00
2023-10-18 12:11:53 +11:00
2026-02-01 10:27:18 +11:00
2025-12-20 19:11:48 +11:00
2025-05-03 16:34:21 +10:00
2024-02-24 15:14:21 +11:00
2024-02-21 14:50:55 +11:00
2025-12-14 19:41:45 +11:00
2024-02-24 15:03:30 +11:00
2025-12-06 19:08:37 +11:00