X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/ba61b04b47e497f8519eed53c78864c08bfc8669..c1c11cfc43014f1516a1f7e4c637622fb10129b8:/src/lib.rs?ds=sidebyside diff --git a/src/lib.rs b/src/lib.rs index 70dfb52..c1a4761 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -313,7 +313,12 @@ fn render_instances(instances: &[Option]) -> HTML { fn render_cell(config: &Config, col: &str, row: &mut Row) -> HTML { let row_label = HTML::escape(row.label.as_ref()); - let col_label = HTML::escape(col); + let col_label = HTML::escape( + config + .substitute_labels + .get(col) + .map_or(col, std::string::String::as_str), + ); let instances: Option<&Vec>> = row.entries.get(col); let is_empty = match instances { None => true, @@ -975,6 +980,25 @@ mod tests { ), HTML::from( r#"nope +"# + ) + ); + assert_eq!( + render_row( + &Config { + column_threshold: 0, + static_columns: vec![], + hidden_columns: HashSet::new(), + substitute_labels: HashMap::from([("foo".to_owned(), "bar".to_owned())]), + }, + &["foo".to_owned()], + &mut Rowlike::Row(Row { + label: "nope".to_owned(), + entries: HashMap::from([("foo".to_owned(), vec![None])]), + }) + ), + HTML::from( + r#"nope𝍷 "# ) );