kkew3 / tabulate

Multiline fixed-width plaintext table generator
MIT License
4 stars 1 forks source link

Add a horizontal line under the heading line #1

Open rahji opened 4 weeks ago

rahji commented 4 weeks ago

This is a great script, thanks! Since the horizontal lines are all created as dashes, the markdown table is rendered without a horizontal line under it. It would be nice if you had the option to create the table with equal signs instead.

In the meantime, this command will do it:

sed -i 'N;/^[^-]*-/{n;s/-/=/g;:a;n;ba};P;D' table.md

:)

kkew3 commented 3 weeks ago

I'm not an expert in sed. So I run your sed script on example-formatted.txt, and it returns this text:

+----------------+----------------------------------------------------------+
| Usage          | tabulate [-h] [-W WIDTH_LIST] [FILE]                     |
+================+==========================================================+
| Description    | Make fixed-width plaintext table with multi-line cell    |
|                | supports. Currently only support grid table, but it's    |
|                | trivial to adapt it to other layout once the table has   |
|                | been built. What plaintext table content is expected:    |
|                | <TAB> will be regarded as field delimiter, <LF> (or      |
|                | <CRLF> if on Windows) as row delimiter, and all the      |
|                | others as cell content.                                  |
+----------------+----------------------------------------------------------+
| FILE           | table content from which to read; if FILE is not         |
|                | specified, the table content will be expected from stdin |
+----------------+----------------------------------------------------------+
| -h, --help     | show this help message and exit                          |
+----------------+----------------------------------------------------------+

which basically renders the second --- row as === row.

Is this what you want?

rahji commented 3 weeks ago

Yes. If you look at section 8.9.4 Extension: grid_tables on this page https://pandoc.org/chunkedhtml-demo/8.9-tables.html you'll see the same thing in their example. What it does is make sure there's a horizontal line under the heading row when it gets rendered.