]> git.scottworley.com Git - tablify/blobdiff - src/lib.rs
Tweak appearance of spacer rows
[tablify] / src / lib.rs
index e11f08b7f623f921b4df1ead0f429d318c7f6219..fbadb2a2bab44e937bf39f51b1a7836c85f32d81 100644 (file)
@@ -18,6 +18,7 @@ const HEADER: &str = r#"<!DOCTYPE html>
     /* h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html */
     th, td { white-space: nowrap; }
     th { text-align: left; font-weight: normal; }
     /* h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html */
     th, td { white-space: nowrap; }
     th { text-align: left; font-weight: normal; }
+    th.spacer_row { height: .3em; }
     table { border-collapse: collapse }
     tr.key > th { height: 10em; vertical-align: bottom; line-height: 1 }
     tr.key > th > div { width: 1em; }
     table { border-collapse: collapse }
     tr.key > th { height: 10em; vertical-align: bottom; line-height: 1 }
     tr.key > th > div { width: 1em; }
@@ -138,7 +139,7 @@ impl<Input: Iterator<Item = Result<String, std::io::Error>>> Iterator for Reader
                     InputLine::Blank if self.row.is_some() => {
                         return Ok(std::mem::take(&mut self.row).map(Rowlike::Row)).transpose()
                     }
                     InputLine::Blank if self.row.is_some() => {
                         return Ok(std::mem::take(&mut self.row).map(Rowlike::Row)).transpose()
                     }
-                    InputLine::Blank => {}
+                    InputLine::Blank => return Some(Ok(Rowlike::Spacer)),
                     InputLine::Entry(col, instance) => match &mut self.row {
                         None => {
                             return Some(Err(std::io::Error::other(format!(
                     InputLine::Entry(col, instance) => match &mut self.row {
                         None => {
                             return Some(Err(std::io::Error::other(format!(
@@ -265,7 +266,7 @@ fn render_all_leftovers(row: &Row) -> HTML {
 
 fn render_row(columns: &[String], rowlike: &mut Rowlike) -> HTML {
     match rowlike {
 
 fn render_row(columns: &[String], rowlike: &mut Rowlike) -> HTML {
     match rowlike {
-        Rowlike::Spacer => HTML::from("<tr><td>&nbsp;</td></tr>"),
+        Rowlike::Spacer => HTML::from("<tr><th class=\"spacer_row\"></th></tr>\n"),
         Rowlike::Row(row) => {
             let row_label = HTML::escape(row.label.as_ref());
             let cells = columns
         Rowlike::Row(row) => {
             let row_label = HTML::escape(row.label.as_ref());
             let cells = columns
@@ -419,6 +420,7 @@ mod tests {
                     label: "foo".to_owned(),
                     entries: HashMap::new(),
                 }),
                     label: "foo".to_owned(),
                     entries: HashMap::new(),
                 }),
+                Rowlike::Spacer,
                 Rowlike::Row(Row {
                     label: "bar".to_owned(),
                     entries: HashMap::new(),
                 Rowlike::Row(Row {
                     label: "bar".to_owned(),
                     entries: HashMap::new(),