(mut self, lines: &mut Vec<Line<'static>>, theme: &Theme)
| 64 | } |
| 65 | |
| 66 | fn render(mut self, lines: &mut Vec<Line<'static>>, theme: &Theme) { |
| 67 | self.finish_row(); |
| 68 | if self.rows.is_empty() { |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | let col_count = self |
| 73 | .rows |
| 74 | .iter() |
| 75 | .map(|row| row.cells.len()) |
| 76 | .max() |
| 77 | .unwrap_or(0) |
| 78 | .max(self.alignments.len()); |
| 79 | if col_count == 0 { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | let mut widths = vec![1usize; col_count]; |
| 84 | for row in &self.rows { |
| 85 | for (idx, cell) in row.cells.iter().enumerate() { |
| 86 | widths[idx] = widths[idx].max(cell_span_width(cell)); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | lines.push(table_border_line( |
| 91 | '┌', |
| 92 | '┬', |
| 93 | '┐', |
| 94 | &widths, |
| 95 | theme.markdown_horizontal_rule, |
| 96 | )); |
| 97 | |
| 98 | for (idx, row) in self.rows.iter().enumerate() { |
| 99 | lines.push(table_row_line(row, &widths, &self.alignments, theme)); |
| 100 | |
| 101 | let is_header_break = |
| 102 | row.is_header && self.rows.get(idx + 1).is_some_and(|next| !next.is_header); |
| 103 | if is_header_break { |
| 104 | lines.push(table_border_line( |
| 105 | '├', |
| 106 | '┼', |
| 107 | '┤', |
| 108 | &widths, |
| 109 | theme.markdown_horizontal_rule, |
| 110 | )); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | lines.push(table_border_line( |
| 115 | '└', |
| 116 | '┴', |
| 117 | '┘', |
| 118 | &widths, |
| 119 | theme.markdown_horizontal_rule, |
| 120 | )); |
| 121 | } |
| 122 | } |
| 123 |
no test coverage detected