Commit b99f417
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>1 parent a2f8c90 commit b99f417
File tree
4 files changed
+138
-21
lines changed- pkg/yqlib
- doc/usage
4 files changed
+138
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
372 | 374 | | |
373 | 375 | | |
374 | 376 | | |
375 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
376 | 381 | | |
377 | 382 | | |
378 | 383 | | |
| |||
384 | 389 | | |
385 | 390 | | |
386 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
171 | 169 | | |
172 | 170 | | |
173 | 171 | | |
| |||
429 | 427 | | |
430 | 428 | | |
431 | 429 | | |
432 | | - | |
| 430 | + | |
| 431 | + | |
433 | 432 | | |
434 | 433 | | |
435 | 434 | | |
436 | 435 | | |
437 | 436 | | |
438 | 437 | | |
439 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
440 | 443 | | |
441 | 444 | | |
442 | 445 | | |
| |||
464 | 467 | | |
465 | 468 | | |
466 | 469 | | |
467 | | - | |
| 470 | + | |
468 | 471 | | |
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
472 | 475 | | |
473 | | - | |
474 | 476 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 477 | + | |
479 | 478 | | |
480 | 479 | | |
481 | 480 | | |
| |||
599 | 598 | | |
600 | 599 | | |
601 | 600 | | |
602 | | - | |
| 601 | + | |
| 602 | + | |
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
606 | | - | |
607 | | - | |
608 | | - | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
609 | 616 | | |
610 | 617 | | |
611 | 618 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| |||
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
266 | 299 | | |
267 | 300 | | |
268 | 301 | | |
| |||
506 | 539 | | |
507 | 540 | | |
508 | 541 | | |
509 | | - | |
| 542 | + | |
510 | 543 | | |
511 | 544 | | |
512 | 545 | | |
| |||
605 | 638 | | |
606 | 639 | | |
607 | 640 | | |
608 | | - | |
| 641 | + | |
609 | 642 | | |
610 | 643 | | |
611 | 644 | | |
| |||
614 | 647 | | |
615 | 648 | | |
616 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
617 | 678 | | |
618 | 679 | | |
619 | 680 | | |
| |||
629 | 690 | | |
630 | 691 | | |
631 | 692 | | |
| 693 | + | |
| 694 | + | |
632 | 695 | | |
633 | 696 | | |
634 | 697 | | |
| |||
654 | 717 | | |
655 | 718 | | |
656 | 719 | | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
657 | 742 | | |
658 | 743 | | |
659 | 744 | | |
| |||
687 | 772 | | |
688 | 773 | | |
689 | 774 | | |
| 775 | + | |
| 776 | + | |
690 | 777 | | |
691 | 778 | | |
692 | 779 | | |
| |||
0 commit comments