nushell/crates/nu-command/src/formats/to
Marco Cunha f41b1460aa
Fix #14660: to md breaks on tables with empty values (#15631)
Fixes #14660

# Description
Fixed an issue where tables with empty values were incorrectly replaced
with [table X row] when converted to Markdown using the ```to md```
command.
Empty values are now replaced with whitespaces to preserve the original
table structure.
Additionally, fixed a missing newline (\n) between tables when using
--per-element in a list.
Removed (\n) from 2 examples for consistency.

Example:

```
For the list
let list = [ {name: bob, age: 21} {name: jim, age: 20} {name: sarah}]

Running "$list | to md --pretty" outputs:

| name  | age |
| ----- | --- |
| bob   | 21  |
| jim   | 20  |
| sarah |     |

------------------------------------------------------------------------------------------------

For the list
let list = [ {name: bob, age: 21} {name: jim, age: 20} {name: sarah} {name: timothy, age: 50} {name: paul} ]

Running "$list | to md --per-element --pretty" outputs:

| name    | age |
| ------- | --- |
| bob     | 21  |
| jim     | 20  |
| timothy | 50  |
| name  |
| ----- |
| sarah |
| paul  |
```

# User-Facing Changes
The ```to md``` behaves as expected when piping a table that contains
empty values showing all rows and the empty items replaced with
whitespace.

# Tests + Formatting
Added 2 test cases to cover both issues.
fmt + clippy OK.

# After Submitting
The command documentation needs to be updated with an example for when
you want to "separate list into markdown tables"
2025-04-24 09:09:48 -05:00
..
command.rs Change the usage misnomer to "description" (#13598) 2024-08-22 12:02:08 +02:00
csv.rs Make IR the default evaluator (#13718) 2024-09-15 14:54:38 -07:00
delimited.rs Refactor I/O Errors (#14927) 2025-01-28 16:03:31 -06:00
json.rs Unify closure serializing logic for to nuon, to msgpack, and to json (#15285) 2025-03-16 20:15:02 +01:00
md.rs Fix #14660: to md breaks on tables with empty values (#15631) 2025-04-24 09:09:48 -05:00
mod.rs bugfix: add "to yml" command (#15254) 2025-03-06 14:32:36 +01:00
msgpack.rs Unify closure serializing logic for to nuon, to msgpack, and to json (#15285) 2025-03-16 20:15:02 +01:00
msgpackz.rs Unify closure serializing logic for to nuon, to msgpack, and to json (#15285) 2025-03-16 20:15:02 +01:00
nuon.rs Unify closure serializing logic for to nuon, to msgpack, and to json (#15285) 2025-03-16 20:15:02 +01:00
text.rs Bugfix chrono panic + hotifx PR15544 (#15549) 2025-04-11 11:52:42 -05:00
toml.rs more closure serialization (#14698) 2025-01-07 11:51:22 -06:00
tsv.rs Make IR the default evaluator (#13718) 2024-09-15 14:54:38 -07:00
xml.rs Bump quick-xml to 0.37.0 (#14354) 2024-11-18 18:26:31 -06:00
yaml.rs bugfix: add "to yml" command (#15254) 2025-03-06 14:32:36 +01:00