diff options
author | Pierre-Henri Symoneaux <phsym@users.noreply.github.com> | 2019-08-26 09:57:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-26 09:57:24 +0200 |
commit | bdfb15081cf5e44934a08941f18a6eaba8275e1e (patch) | |
tree | 2196d98f4c791f2ab9efdfe921805a683330164a /src/row.rs | |
parent | 1e06ea72ccf03cd2129d104360e1e07679190a07 (diff) | |
parent | 19805573d9260c074f19442b02d62cb8a1769913 (diff) |
Merge pull request #101 from jonasbb/html-and-evcxr-integration
Html and Evcxr integration
Diffstat (limited to 'src/row.rs')
-rw-r--r-- | src/row.rs | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -205,6 +205,21 @@ impl Row { -> Result<usize, Error> { self.__print(out, format, col_width, Cell::print_term) } + + /// Print the row in HTML format to `out`. + /// + /// If the row is has fewer columns than `col_num`, the row is padded with empty cells. + pub fn print_html<T: Write + ?Sized>(&self, out: &mut T, col_num: usize) -> Result<(), Error> { + let mut printed_columns = 0; + for cell in self.iter() { + printed_columns += cell.print_html(out)?; + } + // Pad with empty cells, if target width is not reached + for _ in 0..col_num - printed_columns { + Cell::default().print_html(out)?; + } + Ok(()) + } } impl Default for Row { |