mirror of
https://github.com/nushell/nushell.git
synced 2025-06-18 07:56:56 +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",
|
"fancy-regex",
|
||||||
"heck",
|
"heck",
|
||||||
"itertools 0.13.0",
|
"itertools 0.13.0",
|
||||||
|
"mime",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
"nu-cmd-base",
|
"nu-cmd-base",
|
||||||
"nu-cmd-lang",
|
"nu-cmd-lang",
|
||||||
|
@ -34,6 +34,7 @@ serde = { workspace = true }
|
|||||||
serde_urlencoded = { workspace = true }
|
serde_urlencoded = { workspace = true }
|
||||||
v_htmlescape = { workspace = true }
|
v_htmlescape = { workspace = true }
|
||||||
itertools = { workspace = true }
|
itertools = { workspace = true }
|
||||||
|
mime = { workspace = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.101.1" }
|
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.101.1" }
|
||||||
|
@ -330,7 +330,12 @@ fn to_html(
|
|||||||
output_string = run_regexes(®ex_hm, &output_string);
|
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 {
|
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]
|
#[test]
|
||||||
fn out_html_partial() {
|
fn out_html_partial() {
|
||||||
let actual = nu!(r#"
|
let actual = nu!(r#"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user