From 22ba4c2a2fd3d45cbe9e1ef867a1efd28f9ddd3f Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 16 Mar 2020 20:19:18 +1300 Subject: [PATCH] Add svg support to to-html (#1492) --- crates/nu-cli/src/commands/to_html.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/commands/to_html.rs b/crates/nu-cli/src/commands/to_html.rs index d18cb0024e..d7d70de3c9 100644 --- a/crates/nu-cli/src/commands/to_html.rs +++ b/crates/nu-cli/src/commands/to_html.rs @@ -60,7 +60,7 @@ fn to_html(args: CommandArgs, registry: &CommandRegistry) -> Result { let extension = f.split('.').last().map(String::from); match extension { - Some(s) if ["png", "jpg", "bmp", "gif", "tiff"].contains(&s.as_str()) => { + Some(s) if ["png", "jpg", "bmp", "gif", "tiff", "jpeg"].contains(&s.as_str()) => { output_string.push_str(" Result {} } } + UntaggedValue::Primitive(Primitive::String(ref b)) => { + // This might be a bit much, but it's fun :) + match row.tag.anchor { + Some(AnchorLocation::Url(f)) | + Some(AnchorLocation::File(f)) => { + let extension = f.split('.').last().map(String::from); + match extension { + Some(s) if s == "svg" => { + output_string.push_str(""); + continue; + } + _ => {} + } + } + _ => {} + } + output_string.push_str(&(htmlescape::encode_minimal(&format_leaf(&row.value).plain_string(100_000)).replace("\n", "
"))); + } UntaggedValue::Row(row) => { output_string.push_str(""); for header in &headers {