larswaechter / voici.js

A Node.js library for pretty printing your data on the terminal🎨
https://voici.larswaechter.dev
MIT License
335 stars 4 forks source link

Remove leading space after line break #5

Closed larswaechter closed 1 year ago

larswaechter commented 1 year ago

(Leading) empty spaces in a cell should be removed. That happens especially if the next character after a line break is an empty space.

An example:

const data = [['abcdefghijklmnopqrstu', 'abcdefghijklmno pqrstu']];

const table = new Table(data, {
  header: {
    width: 15
  }
});

table.print();

Output: (wrong)

  0                  1                
======================================
  abcdefghijklmno    abcdefghijklmno  
  pqrstu              pqrstu          

As you can see, the empty space before 'p' should be removed.

Correct:

  0                  1                
======================================
  abcdefghijklmno    abcdefghijklmno  
  pqrstu             pqrstu