The EVCXR Kernel supports custom display routines for your types. Implement Debug
like so.
use std::fmt::Debug;
pub struct List<T>(Vec<T>);
impl<T: Debug> List<T> {
pub fn evcxr_display(&self) {
let mut html = String::new();
html.push_str("<ol>");
for item in &self.0 {
html.push_str(&format!("<li>{:?}</li>", item));
}
html.push_str("</ol>");
println!("EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT", html);
}
}
A type implementing Debug
in this way will render HTML. Raster images, SVG, and HTML snippets will all render inline.
let list = List(vec!["the good", "the bad", "the ugly"]);
list