X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/defb3aedeec6589c054ebf909d54ef1f94e5d52a..1ca87bfadfa61703dde1cfc224cec881a68a4f56:/src/lib.rs diff --git a/src/lib.rs b/src/lib.rs index 2e9c7f6..3f3dde5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ struct Config { static_columns: Vec>, hidden_columns: HashSet, substitute_labels: HashMap, + mark: HashMap, } impl Config { fn apply_command(&mut self, line_num: usize, cmd: &str) -> Result<(), std::io::Error> { @@ -60,6 +61,7 @@ impl Default for Config { static_columns: vec![], hidden_columns: HashSet::new(), substitute_labels: HashMap::new(), + mark: HashMap::new(), } } } @@ -338,7 +340,7 @@ fn render_cell(config: &Config, col: &str, row: &mut Row) -> HTML { )) } -fn render_leftover(notcol: &str, instances: &[Option]) -> HTML { +fn render_leftover(config: &Config, notcol: &str, instances: &[Option]) -> HTML { let label = HTML::escape(notcol); if instances.len() == 1 && instances[0].is_none() { HTML(format!("{label}")) @@ -358,7 +360,13 @@ fn render_all_leftovers(config: &Config, row: &Row) -> HTML { HTML( order .into_iter() - .map(|notcol| render_leftover(notcol, row.entries.get(notcol).expect("Key vanished?!"))) + .map(|notcol| { + render_leftover( + config, + notcol, + row.entries.get(notcol).expect("Key vanished?!"), + ) + }) .map(|html| html.0) // Waiting for slice_concat_trait to stabilize .collect::>() .join(", "), @@ -874,6 +882,7 @@ mod tests { static_columns: vec![], hidden_columns: HashSet::from(["private".to_owned()]), substitute_labels: HashMap::new(), + mark: HashMap::new(), }, &Row { label: "nope".to_owned(), @@ -907,6 +916,7 @@ mod tests { static_columns: vec![Some("foo".to_owned()), Some("bar".to_owned())], hidden_columns: HashSet::new(), substitute_labels: HashMap::new(), + mark: HashMap::new(), }, &["baz".to_owned()], &mut Rowlike::Row(Row { @@ -930,6 +940,7 @@ mod tests { static_columns: vec![Some("foo".to_owned()), None, Some("bar".to_owned())], hidden_columns: HashSet::new(), substitute_labels: HashMap::new(), + mark: HashMap::new(), }, &[], &mut Rowlike::Row(Row { @@ -952,6 +963,7 @@ mod tests { static_columns: vec![], hidden_columns: HashSet::from(["foo".to_owned()]), substitute_labels: HashMap::new(), + mark: HashMap::new(), }, &[], &mut Rowlike::Row(Row { @@ -971,6 +983,7 @@ mod tests { static_columns: vec![Some("foo".to_owned())], hidden_columns: HashSet::from(["foo".to_owned()]), substitute_labels: HashMap::new(), + mark: HashMap::new(), }, &[], &mut Rowlike::Row(Row { @@ -990,6 +1003,7 @@ mod tests { static_columns: vec![], hidden_columns: HashSet::new(), substitute_labels: HashMap::from([("foo".to_owned(), "bar".to_owned())]), + mark: HashMap::new(), }, &["foo".to_owned()], &mut Rowlike::Row(Row {