is it possible to print simple tables separated by space?
srghma opened this issue · 5 comments
text text text
texttext text texttext
probably no quchen/prettyprinter#53
basically I would like to have something like this
https://user-images.githubusercontent.com/7573215/152129507-4a20dd26-3ae3-4c55-bfc4-3b383be305cd.png
It would be non-trivial to support in a first class way. Like the linked ticket says, wadler/leijen style printing is not a general-purpose layout algorithm. dodo
has experimental support for local overrides
purescript-dodo-printer/src/Dodo.purs
Lines 197 to 200 in 540dba0
purescript-dodo-printer/src/Dodo.purs
Lines 97 to 99 in 540dba0
Doc
and get a Doc
back. You could potentially write a Doc
printer, that is, a printer that prints Docs back into Doc
, or in some other intermediate boxes-like structure that you can manipulate back into the expected form.You could potentially write a Doc printer, that is, a printer that prints Docs back into Doc, or in some other intermediate boxes-like structure that you can manipulate back into the expected form.
I've run some experiments, and I think this will work as long as you assume annotations are distributive. I'll try to tighten my implementation up over the next few days.
As an example, here it is working with ansi graphics:
With some high-level code:
test :: Doc GraphicsParam
test = Box.toDoc do
let
a =
heading
(textBox 40 (Ansi.bold $ Dodo.text "Heading 1"))
(textBox 40 (Ansi.italic para1))
b =
heading
(textBox 60 (Ansi.bold $ Dodo.text "Heading 2"))
(textBox 60 (Ansi.foreground Ansi.Yellow para1))
a `hgutter 3` b