1 use std::borrow::ToOwned;
2 use std::collections::{HashMap, HashSet};
5 use std::iter::Iterator;
7 fn tally_marks(n: usize) -> String {
8 let fives = { 0..n / 5 }.map(|_| '𝍸');
9 let ones = { 0..n % 5 }.map(|_| '𝍷');
10 fives.chain(ones).collect()
13 #[derive(PartialEq, Eq, Debug)]
15 column_threshold: usize,
16 static_columns: Vec<Option<String>>,
17 hidden_columns: HashSet<String>,
18 substitute_labels: HashMap<String, String>,
19 mark: HashMap<String, String>,
22 fn apply_command(&mut self, line_num: usize, cmd: &str) -> Result<(), std::io::Error> {
23 if let Some(threshold) = cmd.strip_prefix("col_threshold ") {
24 self.column_threshold = threshold.parse().map_err(|e| {
26 std::io::ErrorKind::InvalidInput,
27 format!("line {line_num}: col_threshold must be numeric: {e}"),
30 } else if let Some(col) = cmd.strip_prefix("hide ") {
31 self.hidden_columns.insert(col.to_owned());
32 } else if let Some(col) = cmd.strip_prefix("col ") {
33 self.static_columns.push(Some(col.to_owned()));
34 } else if cmd == "colsep" {
35 self.static_columns.push(None);
36 } else if let Some(directive) = cmd.strip_prefix("label ") {
37 match directive.split_once(':') {
39 return Err(std::io::Error::new(
40 std::io::ErrorKind::InvalidInput,
41 format!("line {line_num}: Annotation missing ':'"),
44 Some((col, label)) => self
46 .insert(col.to_owned(), label.to_owned()),
49 return Err(std::io::Error::new(
50 std::io::ErrorKind::InvalidInput,
51 format!("line {line_num}: Unknown command: {cmd}"),
57 impl Default for Config {
58 fn default() -> Self {
61 static_columns: vec![],
62 hidden_columns: HashSet::new(),
63 substitute_labels: HashMap::new(),
69 const HEADER: &str = r#"<!DOCTYPE html>
72 <meta charset="utf-8">
73 <meta name="viewport" content="width=device-width, initial-scale=1">
75 td { text-align: center; }
76 /* h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html */
77 th, td { white-space: nowrap; }
78 th { text-align: left; font-weight: normal; }
79 th.spacer_row { height: .3em; }
80 .spacer_col { border: none; width: .2em; }
81 table { border-collapse: collapse }
82 tr.key > th { height: 10em; vertical-align: bottom; line-height: 1 }
83 tr.key > th > div { width: 1em; }
84 tr.key > th > div > div { width: 5em; transform-origin: bottom left; transform: translateX(1em) rotate(-65deg) }
85 td { border: thin solid gray; }
86 td.leftover { text-align: left; border: none; padding-left: .4em; }
87 td.yes { border: thin solid gray; background-color: #eee; }
88 /* h/t https://stackoverflow.com/questions/5687035/css-bolding-some-text-without-changing-its-containers-size/46452396#46452396 */
89 .highlight { text-shadow: -0.06ex 0 black, 0.06ex 0 black; }
92 function highlight(id) { const e = document.getElementById(id); if (e) { e.classList.add( "highlight"); } }
93 function clear_highlight(id) { const e = document.getElementById(id); if (e) { e.classList.remove("highlight"); } }
94 function h2(a, b) { highlight(a); highlight(b); }
95 function ch2(a, b) { clear_highlight(a); clear_highlight(b); }
102 const FOOTER: &str = " </tbody>
107 #[derive(PartialEq, Eq, Debug)]
108 pub struct HTML(String);
110 fn escape(value: &str) -> HTML {
111 let mut escaped: String = String::new();
112 for c in value.chars() {
114 '>' => escaped.push_str(">"),
115 '<' => escaped.push_str("<"),
116 '\'' => escaped.push_str("'"),
117 '"' => escaped.push_str("""),
118 '&' => escaped.push_str("&"),
119 ok_c => escaped.push(ok_c),
125 impl From<&str> for HTML {
126 fn from(value: &str) -> HTML {
127 HTML(String::from(value))
130 impl FromIterator<HTML> for HTML {
131 fn from_iter<T>(iter: T) -> HTML
133 T: IntoIterator<Item = HTML>,
135 HTML(iter.into_iter().map(|html| html.0).collect::<String>())
138 impl std::fmt::Display for HTML {
139 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
140 write!(f, "{}", self.0)
144 #[derive(Debug, PartialEq, Eq)]
148 Entry(&'a str, Option<&'a str>),
151 impl<'a> From<&'a str> for InputLine<'a> {
152 fn from(value: &'a str) -> InputLine<'a> {
153 let trimmed = value.trim_end();
154 if trimmed.is_empty() {
156 } else if let Some(cmd) = trimmed.strip_prefix('!') {
157 InputLine::Command(cmd)
158 } else if !trimmed.starts_with(' ') {
159 InputLine::RowHeader(value.trim())
161 match value.split_once(':') {
162 None => InputLine::Entry(value.trim(), None),
163 Some((col, instance)) => InputLine::Entry(col.trim(), Some(instance.trim())),
169 #[derive(Debug, PartialEq, Eq)]
172 entries: HashMap<String, Vec<Option<String>>>,
175 #[derive(Debug, PartialEq, Eq)]
181 struct Reader<'cfg, Input: Iterator<Item = Result<String, std::io::Error>>> {
182 input: std::iter::Enumerate<Input>,
184 config: &'cfg mut Config,
186 impl<'cfg, Input: Iterator<Item = Result<String, std::io::Error>>> Reader<'cfg, Input> {
187 fn new(config: &'cfg mut Config, input: Input) -> Self {
189 input: input.enumerate(),
195 impl<'cfg, Input: Iterator<Item = Result<String, std::io::Error>>> Iterator
196 for Reader<'cfg, Input>
198 type Item = Result<Rowlike, std::io::Error>;
199 fn next(&mut self) -> Option<Self::Item> {
201 match self.input.next() {
202 None => return Ok(std::mem::take(&mut self.row).map(Rowlike::Row)).transpose(),
203 Some((_, Err(e))) => return Some(Err(e)),
204 Some((n, Ok(line))) => match InputLine::from(line.as_ref()) {
205 InputLine::Command(cmd) => {
206 if let Err(e) = self.config.apply_command(n + 1, cmd) {
210 InputLine::Blank if self.row.is_some() => {
211 return Ok(std::mem::take(&mut self.row).map(Rowlike::Row)).transpose()
213 InputLine::Blank => return Some(Ok(Rowlike::Spacer)),
214 InputLine::Entry(col, instance) => match &mut self.row {
216 return Some(Err(std::io::Error::other(format!(
217 "line {}: Entry with no header",
221 Some(ref mut row) => {
223 .entry(col.to_owned())
224 .and_modify(|is| is.push(instance.map(ToOwned::to_owned)))
225 .or_insert_with(|| vec![instance.map(ToOwned::to_owned)]);
228 InputLine::RowHeader(row) => {
229 let prev = std::mem::take(&mut self.row);
230 self.row = Some(Row {
231 label: row.to_owned(),
232 entries: HashMap::new(),
235 return Ok(prev.map(Rowlike::Row)).transpose();
244 fn read_input(input: impl std::io::Read) -> Result<(Vec<Rowlike>, Config), std::io::Error> {
245 let mut config = Config::default();
246 let reader = Reader::new(&mut config, std::io::BufReader::new(input).lines());
248 .collect::<Result<Vec<_>, _>>()
249 .map(|rows| (rows, config))
252 fn column_counts(rows: &[Rowlike]) -> Vec<(usize, String)> {
253 let empty = HashMap::new();
254 let mut counts: Vec<_> = rows
256 .flat_map(|rl| match rl {
257 Rowlike::Row(r) => r.entries.keys(),
258 Rowlike::Spacer => empty.keys(),
260 .fold(HashMap::new(), |mut cs, col| {
261 cs.entry(col.to_owned())
262 .and_modify(|n| *n += 1)
267 .map(|(col, n)| (n, col))
269 counts.sort_unstable_by(|(an, acol), (bn, bcol)| bn.cmp(an).then(acol.cmp(bcol)));
272 fn column_order(config: &Config, rows: &[Rowlike]) -> Vec<String> {
273 let static_columns: HashSet<&str> = config
277 .map(std::string::String::as_str)
281 .filter_map(|(n, col)| {
282 (n >= config.column_threshold
283 && !static_columns.contains(col.as_str())
284 && !config.hidden_columns.contains(&col))
290 fn render_instances(instances: &[Option<String>]) -> HTML {
292 let mut out = vec![];
293 for ins in instances {
298 out.push(HTML(tally_marks(tally)));
301 out.push(HTML::escape(content));
306 out.push(HTML(tally_marks(tally)));
310 .map(|html| html.0) // Waiting for slice_concat_trait to stabilize
316 fn render_cell(config: &Config, col: &str, row: &mut Row) -> HTML {
317 let row_label = HTML::escape(row.label.as_ref());
318 let col_label = HTML::escape(
322 .map_or(col, std::string::String::as_str),
324 let instances: Option<&Vec<Option<String>>> = row.entries.get(col);
325 let is_empty = match instances {
327 Some(is) => is.iter().all(|ins| match ins {
329 Some(content) => content == "×",
332 let class = HTML::from(if is_empty { "" } else { r#" class="yes""# });
333 let contents = match instances {
334 None => HTML::from(""),
335 Some(is) => render_instances(is),
337 row.entries.remove(col);
339 r#"<td{class} onmouseover="h2('{row_label}','{col_label}')" onmouseout="ch2('{row_label}','{col_label}')">{contents}</td>"#
343 fn render_leftover(notcol: &str, instances: &[Option<String>]) -> HTML {
344 let label = HTML::escape(notcol);
345 if instances.len() == 1 && instances[0].is_none() {
346 HTML(format!("{label}"))
348 let rest = render_instances(instances);
349 HTML(format!("{label}: {rest}"))
353 fn render_all_leftovers(config: &Config, row: &Row) -> HTML {
354 let mut order: Vec<_> = row
357 .filter(|&col| !config.hidden_columns.contains(col))
359 order.sort_unstable();
363 .map(|notcol| render_leftover(notcol, row.entries.get(notcol).expect("Key vanished?!")))
364 .map(|html| html.0) // Waiting for slice_concat_trait to stabilize
370 fn render_row(config: &Config, columns: &[String], rowlike: &mut Rowlike) -> HTML {
372 Rowlike::Spacer => HTML::from("<tr><th class=\"spacer_row\"></th></tr>\n"),
373 Rowlike::Row(row) => {
374 let row_label = HTML::escape(row.label.as_ref());
375 let static_cells = config
378 .map(|ocol| match ocol {
379 Some(col) if config.hidden_columns.contains(col) => HTML::from(""),
380 Some(col) => render_cell(config, col, row),
381 None => HTML::from(r#"<td class="spacer_col"></td>"#),
384 let dynamic_cells = columns
386 .filter(|&col| !config.hidden_columns.contains(col))
387 .map(|col| render_cell(config, col, row))
389 let leftovers = render_all_leftovers(config, row);
391 "<tr><th id=\"{row_label}\">{row_label}</th>{static_cells}{dynamic_cells}<td class=\"leftover\" onmouseover=\"highlight('{row_label}')\" onmouseout=\"clear_highlight('{row_label}')\">{leftovers}</td></tr>\n"
397 fn column_header_labels<'a>(
399 columns: &'a [String],
400 ) -> impl Iterator<Item = Option<&'a String>> {
401 let static_columns = config.static_columns.iter().map(|oc| oc.as_ref());
402 let dynamic_columns = columns.iter().map(Some);
404 .chain(dynamic_columns)
405 .filter(|ocol| ocol.map_or(true, |col| !config.hidden_columns.contains(col)))
407 ocol.map(|col| match config.substitute_labels.get(col) {
409 Some(substitute) => substitute,
414 fn render_column_headers(config: &Config, columns: &[String]) -> HTML {
416 String::from(r#"<tr class="key"><th></th>"#)
417 + &column_header_labels(config, columns).fold(String::new(), |mut acc, ocol| {
420 let col_header = HTML::escape(col);
423 r#"<th id="{col_header}"><div><div>{col_header}</div></div></th>"#
426 None => write!(&mut acc, r#"<th class="col_spacer"></th>"#),
437 /// Will return `Err` if
438 /// * there's an i/o error while reading `input`
439 /// * the log has invalid syntax:
440 /// * an indented line with no preceding non-indented line
441 pub fn tablify(input: impl std::io::Read) -> Result<HTML, std::io::Error> {
442 let (rows, config) = read_input(input)?;
443 let columns = column_order(&config, &rows);
445 "{HEADER}{}{}{FOOTER}",
446 render_column_headers(&config, &columns),
448 .map(|mut r| render_row(&config, &columns, &mut r))
458 fn test_parse_line() {
459 assert_eq!(InputLine::from(""), InputLine::Blank);
460 assert_eq!(InputLine::from(" "), InputLine::Blank);
461 assert_eq!(InputLine::from("foo"), InputLine::RowHeader("foo"));
462 assert_eq!(InputLine::from("foo "), InputLine::RowHeader("foo"));
463 assert_eq!(InputLine::from(" foo"), InputLine::Entry("foo", None));
465 InputLine::from(" foo:bar"),
466 InputLine::Entry("foo", Some("bar"))
469 InputLine::from(" foo: bar"),
470 InputLine::Entry("foo", Some("bar"))
473 InputLine::from(" foo: bar "),
474 InputLine::Entry("foo", Some("bar"))
477 InputLine::from(" foo: bar "),
478 InputLine::Entry("foo", Some("bar"))
481 InputLine::from(" foo : bar "),
482 InputLine::Entry("foo", Some("bar"))
487 fn test_tally_marks() {
488 assert_eq!(tally_marks(1), "𝍷");
489 assert_eq!(tally_marks(2), "𝍷𝍷");
490 assert_eq!(tally_marks(3), "𝍷𝍷𝍷");
491 assert_eq!(tally_marks(4), "𝍷𝍷𝍷𝍷");
492 assert_eq!(tally_marks(5), "𝍸");
493 assert_eq!(tally_marks(6), "𝍸𝍷");
494 assert_eq!(tally_marks(7), "𝍸𝍷𝍷");
495 assert_eq!(tally_marks(8), "𝍸𝍷𝍷𝍷");
496 assert_eq!(tally_marks(9), "𝍸𝍷𝍷𝍷𝍷");
497 assert_eq!(tally_marks(10), "𝍸𝍸");
498 assert_eq!(tally_marks(11), "𝍸𝍸𝍷");
501 fn read_rows(input: impl std::io::Read) -> Result<Vec<Rowlike>, std::io::Error> {
502 read_input(input).map(|(rows, _)| rows)
504 fn read_config(input: impl std::io::Read) -> Result<Config, std::io::Error> {
505 read_input(input).map(|(_, config)| config)
508 fn test_read_rows() {
510 read_rows(&b"foo"[..]).unwrap(),
511 vec![Rowlike::Row(Row {
512 label: "foo".to_owned(),
513 entries: HashMap::new(),
517 read_rows(&b"bar"[..]).unwrap(),
518 vec![Rowlike::Row(Row {
519 label: "bar".to_owned(),
520 entries: HashMap::new(),
524 read_rows(&b"foo\nbar\n"[..]).unwrap(),
527 label: "foo".to_owned(),
528 entries: HashMap::new(),
531 label: "bar".to_owned(),
532 entries: HashMap::new(),
537 read_rows(&b"foo\n bar\n"[..]).unwrap(),
538 vec![Rowlike::Row(Row {
539 label: "foo".to_owned(),
540 entries: HashMap::from([("bar".to_owned(), vec![None])]),
544 read_rows(&b"foo\n bar\n baz\n"[..]).unwrap(),
545 vec![Rowlike::Row(Row {
546 label: "foo".to_owned(),
547 entries: HashMap::from([
548 ("bar".to_owned(), vec![None]),
549 ("baz".to_owned(), vec![None])
554 read_rows(&b"foo\n\nbar\n"[..]).unwrap(),
557 label: "foo".to_owned(),
558 entries: HashMap::new(),
561 label: "bar".to_owned(),
562 entries: HashMap::new(),
567 read_rows(&b"foo\n\n\nbar\n"[..]).unwrap(),
570 label: "foo".to_owned(),
571 entries: HashMap::new(),
575 label: "bar".to_owned(),
576 entries: HashMap::new(),
581 read_rows(&b"foo\n \nbar\n"[..]).unwrap(),
584 label: "foo".to_owned(),
585 entries: HashMap::new(),
588 label: "bar".to_owned(),
589 entries: HashMap::new(),
594 read_rows(&b"foo \n bar \n"[..]).unwrap(),
595 vec![Rowlike::Row(Row {
596 label: "foo".to_owned(),
597 entries: HashMap::from([("bar".to_owned(), vec![None])]),
601 let bad = read_rows(&b" foo"[..]);
602 assert!(bad.is_err());
603 assert!(format!("{bad:?}").contains("line 1: Entry with no header"));
605 let bad2 = read_rows(&b"foo\n\n bar"[..]);
606 assert!(bad2.is_err());
607 assert!(format!("{bad2:?}").contains("line 3: Entry with no header"));
611 fn test_read_config() {
613 read_config(&b"!col_threshold 10"[..])
619 read_config(&b"!col foo"[..]).unwrap().static_columns,
620 vec![Some("foo".to_owned())]
623 read_config(&b"!label foo:bar"[..])
625 .substitute_labels["foo"],
629 let bad_command = read_config(&b"!no such command"[..]);
630 assert!(bad_command.is_err());
631 assert!(format!("{bad_command:?}").contains("line 1: Unknown command"));
633 let bad_num = read_config(&b"!col_threshold foo"[..]);
634 assert!(bad_num.is_err());
635 assert!(format!("{bad_num:?}").contains("line 1: col_threshold must be numeric"));
637 let bad_sub = read_config(&b"!label foo"[..]);
638 assert!(bad_sub.is_err());
639 assert!(format!("{bad_sub:?}").contains("line 1: Annotation missing ':'"));
643 fn test_column_counts() {
645 column_counts(&read_rows(&b"foo\n bar\n baz\n"[..]).unwrap()),
646 vec![(1, String::from("bar")), (1, String::from("baz"))]
649 column_counts(&read_rows(&b"foo\n bar\n baz\nquux\n baz"[..]).unwrap()),
650 vec![(2, String::from("baz")), (1, String::from("bar"))]
653 column_counts(&read_rows(&b"foo\n bar\n bar\n baz\n bar\nquux\n baz"[..]).unwrap()),
654 vec![(2, String::from("baz")), (1, String::from("bar"))]
658 &read_rows(&b"foo\n bar: 1\n bar: 2\n baz\n bar\nquux\n baz"[..]).unwrap()
660 vec![(2, String::from("baz")), (1, String::from("bar"))]
665 fn test_column_header_labels() {
666 let mut cfg = Config::default();
668 assert!(column_header_labels(&cfg, &["foo".to_owned()]).eq([Some(&"foo".to_owned())]));
670 cfg.static_columns.push(Some("bar".to_owned()));
671 assert!(column_header_labels(&cfg, &["foo".to_owned()])
672 .eq([Some(&"bar".to_owned()), Some(&"foo".to_owned())]));
674 cfg.static_columns.push(None);
675 assert!(column_header_labels(&cfg, &["foo".to_owned()]).eq([
676 Some(&"bar".to_owned()),
678 Some(&"foo".to_owned())
681 cfg.substitute_labels
682 .insert("foo".to_owned(), "foo (bits)".to_owned());
683 assert!(column_header_labels(&cfg, &["foo".to_owned()]).eq([
684 Some(&"bar".to_owned()),
686 Some(&"foo (bits)".to_owned())
689 cfg.hidden_columns.insert("foo".to_owned());
690 assert!(column_header_labels(&cfg, &["foo".to_owned()]).eq([Some(&"bar".to_owned()), None]));
692 cfg.hidden_columns.insert("bar".to_owned());
693 assert!(column_header_labels(&cfg, &["foo".to_owned()]).eq([None]));
697 fn test_render_cell() {
703 label: "nope".to_owned(),
704 entries: HashMap::new(),
708 r#"<td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td>"#
716 label: "nope".to_owned(),
717 entries: HashMap::from([("bar".to_owned(), vec![None])]),
721 r#"<td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td>"#
729 label: "nope".to_owned(),
730 entries: HashMap::from([("foo".to_owned(), vec![None])]),
734 r#"<td class="yes" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">𝍷</td>"#
742 label: "nope".to_owned(),
743 entries: HashMap::from([("foo".to_owned(), vec![None, None])]),
747 r#"<td class="yes" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">𝍷𝍷</td>"#
755 label: "nope".to_owned(),
756 entries: HashMap::from([(
758 vec![Some("5".to_owned()), Some("10".to_owned())]
763 r#"<td class="yes" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">5 10</td>"#
771 label: "nope".to_owned(),
772 entries: HashMap::from([("foo".to_owned(), vec![Some("5".to_owned()), None])]),
776 r#"<td class="yes" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">5 𝍷</td>"#
784 label: "nope".to_owned(),
785 entries: HashMap::from([("foo".to_owned(), vec![Some("×".to_owned())])]),
789 r#"<td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">×</td>"#
797 label: "nope".to_owned(),
798 entries: HashMap::from([("heart".to_owned(), vec![Some("<3".to_owned())])]),
802 r#"<td class="yes" onmouseover="h2('nope','heart')" onmouseout="ch2('nope','heart')"><3</td>"#
810 label: "bob's".to_owned(),
811 entries: HashMap::from([("foo".to_owned(), vec![None])]),
815 r#"<td class="yes" onmouseover="h2('bob's','foo')" onmouseout="ch2('bob's','foo')">𝍷</td>"#
819 label: "nope".to_owned(),
820 entries: HashMap::from([
821 ("foo".to_owned(), vec![None]),
822 ("baz".to_owned(), vec![None]),
825 assert_eq!(r.entries.len(), 2);
826 render_cell(&Config::default(), "foo", &mut r);
827 assert_eq!(r.entries.len(), 1);
828 render_cell(&Config::default(), "bar", &mut r);
829 assert_eq!(r.entries.len(), 1);
830 render_cell(&Config::default(), "baz", &mut r);
831 assert_eq!(r.entries.len(), 0);
835 fn test_render_leftovers() {
837 render_all_leftovers(
840 label: "nope".to_owned(),
841 entries: HashMap::from([("foo".to_owned(), vec![None])]),
847 render_all_leftovers(
850 label: "nope".to_owned(),
851 entries: HashMap::from([
852 ("foo".to_owned(), vec![None]),
853 ("bar".to_owned(), vec![None])
857 HTML::from("bar, foo")
860 render_all_leftovers(
863 label: "nope".to_owned(),
864 entries: HashMap::from([
865 ("foo".to_owned(), vec![None]),
866 ("bar".to_owned(), vec![None, None])
870 HTML::from("bar: 𝍷𝍷, foo")
873 render_all_leftovers(
876 static_columns: vec![],
877 hidden_columns: HashSet::from(["private".to_owned()]),
878 substitute_labels: HashMap::new(),
879 mark: HashMap::new(),
882 label: "nope".to_owned(),
883 entries: HashMap::from([("private".to_owned(), vec![None]),]),
891 fn test_render_row() {
896 &mut Rowlike::Row(Row {
897 label: "nope".to_owned(),
898 entries: HashMap::from([("bar".to_owned(), vec![None])]),
902 r#"<tr><th id="nope">nope</th><td onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')"></td><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')">bar</td></tr>
910 static_columns: vec![Some("foo".to_owned()), Some("bar".to_owned())],
911 hidden_columns: HashSet::new(),
912 substitute_labels: HashMap::new(),
913 mark: HashMap::new(),
916 &mut Rowlike::Row(Row {
917 label: "nope".to_owned(),
918 entries: HashMap::from([
919 ("bar".to_owned(), vec![Some("r".to_owned())]),
920 ("baz".to_owned(), vec![Some("z".to_owned())]),
921 ("foo".to_owned(), vec![Some("f".to_owned())]),
926 r#"<tr><th id="nope">nope</th><td class="yes" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">f</td><td class="yes" onmouseover="h2('nope','bar')" onmouseout="ch2('nope','bar')">r</td><td class="yes" onmouseover="h2('nope','baz')" onmouseout="ch2('nope','baz')">z</td><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')"></td></tr>
934 static_columns: vec![Some("foo".to_owned()), None, Some("bar".to_owned())],
935 hidden_columns: HashSet::new(),
936 substitute_labels: HashMap::new(),
937 mark: HashMap::new(),
940 &mut Rowlike::Row(Row {
941 label: "nope".to_owned(),
942 entries: HashMap::from([
943 ("bar".to_owned(), vec![Some("r".to_owned())]),
944 ("foo".to_owned(), vec![Some("f".to_owned())]),
949 r#"<tr><th id="nope">nope</th><td class="yes" onmouseover="h2('nope','foo')" onmouseout="ch2('nope','foo')">f</td><td class="spacer_col"></td><td class="yes" onmouseover="h2('nope','bar')" onmouseout="ch2('nope','bar')">r</td><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')"></td></tr>
957 static_columns: vec![],
958 hidden_columns: HashSet::from(["foo".to_owned()]),
959 substitute_labels: HashMap::new(),
960 mark: HashMap::new(),
963 &mut Rowlike::Row(Row {
964 label: "nope".to_owned(),
965 entries: HashMap::from([("foo".to_owned(), vec![Some("f".to_owned())]),]),
969 r#"<tr><th id="nope">nope</th><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')"></td></tr>
977 static_columns: vec![Some("foo".to_owned())],
978 hidden_columns: HashSet::from(["foo".to_owned()]),
979 substitute_labels: HashMap::new(),
980 mark: HashMap::new(),
983 &mut Rowlike::Row(Row {
984 label: "nope".to_owned(),
985 entries: HashMap::from([("foo".to_owned(), vec![Some("f".to_owned())]),]),
989 r#"<tr><th id="nope">nope</th><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')"></td></tr>
997 static_columns: vec![],
998 hidden_columns: HashSet::new(),
999 substitute_labels: HashMap::from([("foo".to_owned(), "bar".to_owned())]),
1000 mark: HashMap::new(),
1002 &["foo".to_owned()],
1003 &mut Rowlike::Row(Row {
1004 label: "nope".to_owned(),
1005 entries: HashMap::from([("foo".to_owned(), vec![None])]),
1009 r#"<tr><th id="nope">nope</th><td class="yes" onmouseover="h2('nope','bar')" onmouseout="ch2('nope','bar')">𝍷</td><td class="leftover" onmouseover="highlight('nope')" onmouseout="clear_highlight('nope')"></td></tr>