mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 03:44:19 +01:00
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 {
|
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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user