forked from extern/nushell
clean table text before rendering (#4638)
This commit is contained in:
parent
e8a6458f0d
commit
2126bef052
@ -973,8 +973,9 @@ fn process_table(table: &Table) -> ProcessedTable {
|
||||
for row in &table.data {
|
||||
let mut out_row = vec![];
|
||||
for column in row {
|
||||
let cleaned = clean(&column.contents);
|
||||
out_row.push(ProcessedCell {
|
||||
contents: split_sublines(&column.contents),
|
||||
contents: split_sublines(&cleaned),
|
||||
style: column.style,
|
||||
});
|
||||
}
|
||||
@ -983,8 +984,9 @@ fn process_table(table: &Table) -> ProcessedTable {
|
||||
|
||||
let mut processed_headers = vec![];
|
||||
for header in &table.headers {
|
||||
let cleaned = clean(&header.contents);
|
||||
processed_headers.push(ProcessedCell {
|
||||
contents: split_sublines(&header.contents),
|
||||
contents: split_sublines(&cleaned),
|
||||
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> {
|
||||
use std::cmp::max;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user