| 340 | } |
| 341 | |
| 342 | pub(super) fn table(&mut self, headers: &[&str], rows: &[Vec<String>]) -> &mut Self { |
| 343 | if headers.is_empty() { |
| 344 | return self; |
| 345 | } |
| 346 | let _ = writeln!(self.buf, "| {} |", headers.join(" | ")); |
| 347 | let sep: Vec<&str> = headers.iter().map(|_| "---").collect(); |
| 348 | let _ = writeln!(self.buf, "| {} |", sep.join(" | ")); |
| 349 | for row in rows { |
| 350 | let cells: Vec<String> = row.iter().map(|c| esc_cell(c)).collect(); |
| 351 | let _ = writeln!(self.buf, "| {} |", cells.join(" | ")); |
| 352 | } |
| 353 | self |
| 354 | } |
| 355 | |
| 356 | pub(super) fn code(&mut self, lang: &str, body: &str) -> &mut Self { |
| 357 | let _ = writeln!(self.buf, "```{lang}"); |