clean table text before rendering (#4638)

This commit is contained in:
JT 2022-02-25 08:13:55 -05:00 committed by GitHub
parent e8a6458f0d
commit 2126bef052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -973,8 +973,9 @@ fn process_table(table: &Table) -> ProcessedTable {
for row in &table.data { for row in &table.data {
let mut out_row = vec![]; let mut out_row = vec![];
for column in row { for column in row {
let cleaned = clean(&column.contents);
out_row.push(ProcessedCell { out_row.push(ProcessedCell {
contents: split_sublines(&column.contents), contents: split_sublines(&cleaned),
style: column.style, style: column.style,
}); });
} }
@ -983,8 +984,9 @@ fn process_table(table: &Table) -> ProcessedTable {
let mut processed_headers = vec![]; let mut processed_headers = vec![];
for header in &table.headers { for header in &table.headers {
let cleaned = clean(&header.contents);
processed_headers.push(ProcessedCell { processed_headers.push(ProcessedCell {
contents: split_sublines(&header.contents), contents: split_sublines(&cleaned),
style: header.style, style: header.style,
}); });
} }
@ -996,6 +998,12 @@ fn process_table(table: &Table) -> ProcessedTable {
} }
} }
fn clean(input: &str) -> String {
let input = input.replace('\r', "");
input.replace('\t', " ")
}
fn get_max_column_widths(processed_table: &ProcessedTable) -> Vec<usize> { fn get_max_column_widths(processed_table: &ProcessedTable) -> Vec<usize> {
use std::cmp::max; use std::cmp::max;