mirror of
https://github.com/nushell/nushell.git
synced 2025-04-17 17:58:18 +02:00
Supply metadata.content_type
for to html
output (#14990)
# Description Adds pipeline metadata to the `to html` command output (hardcoded to `text/html; charset=utf-8`) # User-Facing Changes Pipeline metadata is now included with the `to html` command output.
This commit is contained in:
parent
8b431e3a2e
commit
4424481487
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3542,6 +3542,7 @@ dependencies = [
|
||||
"fancy-regex",
|
||||
"heck",
|
||||
"itertools 0.13.0",
|
||||
"mime",
|
||||
"nu-ansi-term",
|
||||
"nu-cmd-base",
|
||||
"nu-cmd-lang",
|
||||
|
@ -34,8 +34,9 @@ serde = { workspace = true }
|
||||
serde_urlencoded = { workspace = true }
|
||||
v_htmlescape = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
mime = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.101.1" }
|
||||
nu-command = { path = "../nu-command", version = "0.101.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.101.1" }
|
||||
nu-test-support = { path = "../nu-test-support", version = "0.101.1" }
|
||||
|
@ -330,7 +330,12 @@ fn to_html(
|
||||
output_string = run_regexes(®ex_hm, &output_string);
|
||||
}
|
||||
|
||||
Ok(Value::string(output_string, head).into_pipeline_data())
|
||||
let metadata = PipelineMetadata {
|
||||
data_source: nu_protocol::DataSource::None,
|
||||
content_type: Some(mime::TEXT_HTML_UTF_8.to_string()),
|
||||
};
|
||||
|
||||
Ok(Value::string(output_string, head).into_pipeline_data_with_metadata(metadata))
|
||||
}
|
||||
|
||||
fn theme_demo(span: Span) -> PipelineData {
|
||||
|
@ -14,6 +14,15 @@ fn out_html_simple() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn out_html_metadata() {
|
||||
let actual = nu!(r#"
|
||||
echo 3 | to html | metadata | get content_type
|
||||
"#);
|
||||
|
||||
assert_eq!(actual.out, r#"text/html; charset=utf-8"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn out_html_partial() {
|
||||
let actual = nu!(r#"
|
||||
|
Loading…
Reference in New Issue
Block a user