muesli4 / table-layout

Layout data in grids and pretty tables. Provides a lot of tools to get the cell formatting right (positional alignment, alignment on specific characters and limiting of cell width)..
BSD 3-Clause "New" or "Revised" License
37 stars 11 forks source link

Produce tables that are accepted as input by Pandoc table extensions #5

Closed jbg-mnn closed 4 years ago

jbg-mnn commented 4 years ago

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?

muesli4 commented 4 years ago

@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:

I don't support markdown for horizontal positioning but that should not be so hard to implement.

jbg-mnn commented 4 years ago

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.

muesli4 commented 4 years ago

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.

jbg-mnn commented 4 years ago

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.

muesli4 commented 4 years ago

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:

jbg-mnn commented 4 years ago

Ok, i will then patch the output of tableLines. Thanks anyway.

muesli4 commented 4 years ago

@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.

jbg-mnn commented 4 years ago

That's very kind! Yes, I can wait until beginning of January. Thank you.

muesli4 commented 4 years ago

@jbg-mnn I added a module Text.Layout.Table.Pandoc that provides a function for pipe_tables. I might also support grid_tables in the future but that requires a bit more refactoring.

Please let me know whether that works out for you and whether you need a release on hackage.