columnify icon indicating copy to clipboard operation
columnify copied to clipboard

Separate Header with a -------

Open blak3r2 opened this issue 8 years ago • 3 comments

Would love an option to separate the column headers from the body of the table with a line.

I love the truncation and autowrap features of your module. But, for some of my tables having a table separator looks a lot cleaner in my opinion.

Using tablify:

image

Using columnify

image

blak3r2 avatar Mar 21 '16 02:03 blak3r2

+1

hustcer avatar Apr 27 '16 01:04 hustcer

+1. I added the following line to add '----' after header.

col = col.slice(0, col.indexOf('\n')) + '\n' +'-'.repeat(col.indexOf('\n')) + col.slice(col.indexOf('\n'));

bladerunner2020 avatar Jan 25 '17 17:01 bladerunner2020

I did it by doing a simple function that adds the dashes

const addDashes = (text: string) => {
    const repeat = () => `${'-'.repeat(30)}`;
    return `${repeat()}\n${text}\n${repeat()}`
}

and then calling the function in my config.headingTransform. Like this:

columnify(data,{headingTransform: text => addDashes(text)})

Home someone can use this snippet

arelstone avatar Mar 03 '20 08:03 arelstone