From a06299c77a1d0cd4f1f76ff045facec93b931bbb Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 2 Jun 2022 15:34:31 -0700 Subject: [PATCH] Improve output of 'to html', (#5699) * Fix
output of 'to html', Specifically, add and elements. That allows for better styling and (future) some neat JavaScript. * Update tests for previous
changes. --- crates/nu-command/src/formats/to/html.rs | 12 ++++++------ crates/nu-command/tests/format_conversions/html.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/nu-command/src/formats/to/html.rs b/crates/nu-command/src/formats/to/html.rs index a36d13569..9a363e4ac 100644 --- a/crates/nu-command/src/formats/to/html.rs +++ b/crates/nu-command/src/formats/to/html.rs @@ -118,21 +118,21 @@ impl Command for ToHtml { description: "Outputs an HTML string representing the contents of this table", example: "[[foo bar]; [1 2]] | to html", result: Some(Value::test_string( - r#"
foobar
12
"#, + r#"
foobar
12
"#, )), }, Example { description: "Optionally, only output the html for the content itself", example: "[[foo bar]; [1 2]] | to html --partial", result: Some(Value::test_string( - r#"
foobar
12
"#, + r#"
foobar
12
"#, )), }, Example { description: "Optionally, output the string with a dark background", example: "[[foo bar]; [1 2]] | to html --dark", result: Some(Value::test_string( - r#"
foobar
12
"#, + r#"
foobar
12
"#, )), }, ] @@ -360,13 +360,13 @@ fn html_table(table: Vec, headers: Vec, config: &Config) -> Strin output_string.push_str(""); - output_string.push_str(""); + output_string.push_str(""); for header in &headers { output_string.push_str(""); } - output_string.push_str(""); + output_string.push_str(""); for row in table { if let Value::Record { span, .. } = row { @@ -383,7 +383,7 @@ fn html_table(table: Vec, headers: Vec, config: &Config) -> Strin output_string.push_str(""); } } - output_string.push_str("
"); output_string.push_str(&htmlescape::encode_minimal(header)); output_string.push_str("
"); + output_string.push_str(""); output_string } diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs index 5e36b3d0e..9319b9442 100644 --- a/crates/nu-command/tests/format_conversions/html.rs +++ b/crates/nu-command/tests/format_conversions/html.rs @@ -41,7 +41,7 @@ fn out_html_table() { assert_eq!( actual.out, - r"
name
darren
" + r"
name
darren
" ); }