Produce tables that are accepted as input by Pandoc table extensions
Closed this issue · 9 comments
What about markdown support for horizontal positioning with ':'?
The asciiS style is almost there with asciiS { headerSepH = '=' }
.
But the colons for horizontal positioning are missing. Could you imagine to add it?
@jbg-mnn I can't say that I understand your description. Can you give me an example?
There are 2 concepts for horizontal positioning in this library:
- Align a string in a cell by position (i.e. by using
left
,right
,center
). - Align a string by using the combinators
charAlign
orpredAlign
. This will align the cell content of all cells in a column by the matched position.
I don't support markdown for horizontal positioning but that should not be so hard to implement.
I would like to have support in Text.Layout.Table.Style similar to headerSepH
for the colons in a markdown horizontal positioning specification as in the following example:
+---------+---------+---------+
| columnA | columnB | columnC |
+:========+:=======:+========:+
| left | center | right |
+---------+---------+---------+
In the header separation line of columnA the left colon indicates left horizontal positioning, in columnB the two colons indicate centered positioning, and in columnC the right colon indicates right positioning.
I don't see how that is markdown. Markdown means you add format commands to the input. However, your example shows output. Do you want to add indicators to the table that show how content is aligned?
It shouldn't be too hard to implement. However, I'm not sure how useful this feature is.
Please see pandoc extensions grid_tables and pipe_tables as described here: https://pandoc.org/MANUAL.html#tables. Both extensions support horizontal alignment specification using the colon notation. My example was intended to feed it into the pandoc toolchain.
I see. Well, the functions for producing tables are not made for that purpose and I think it would make the generation a bit too complicated. Maybe I could provide an extra function that generates output for pipe_tables
.
The way to implement that is probably on top of grid
:
- Use the first row of the grid with
map $ const '-'
and insert:
according to the position used. - Add pipes in between and at the sides.
Ok, i will then patch the output of tableLines. Thanks anyway.
@jbg-mnn I have something prepared already but not yet decided how and where. If you have time to wait to until around Christmas then I might do another release.
That's very kind! Yes, I can wait until beginning of January. Thank you.