Welcome! Please see the About page for a little more info on how this works.

0 votes
in Printing by

When using print-table to print an ASCII table to stdout, the table display breaks if any of the values is a string with any new lines in it. For example:

`
user=> (print-table [{:a "test" :b "test\ntest2"}])

| :a | :b |
|------+------------|
| test | test
test2 |
nil
`

I would expect the output to look something like this:

`
user=> (print-table [{:a "test" :b "test\ntest2"}])

| :a | :b |
|------+------------|
| test | test +
| | test2 |
nil
`

The + symbol on the right border means that the row continues over multiple lines. This is similar to how the PostgreSQL psql tool displays table with multi-line rows:

`
user=# select 'test' col1, E'test\ntest2\ntest3' col2;
col1 | col2
------+-------
test | test +

  | test2+
  | test3

(1 row)

Time: 0.776 ms
`

3 Answers

0 votes
by

Comment made by: benwbooth@gmail.com

JIRA destroyed my formatting, and looks like I can't edit it to fix it. Here is what I meant to say:

When using print-table to print an ASCII table to stdout, the table display breaks if any of the values is a string with any new lines in it. For example:

`
user=> (print-table [{:a "test" :b "test\ntest2"}])

| :a | :b |
|------+------------|
| test | test
test2 |
`

I would expect the output to look something like this:

user=> (print-table [{:a "test" :b "test\ntest2"}]) | :a | :b | |------+------------| | test | test + | | test2 |

The + symbol on the right border means that the row continues over multiple lines. This is similar to how the PostgreSQL psql tool displays table with multi-line rows:

`
labtrack=# select 'test' col1, E'test\ntest2' col2;
col1 | col2
------+-------
test | test +

  | test2

(1 row)
`

0 votes
by

Comment made by: jafingerhut

I have no direct knowledge of this, but my guess would be that the Clojure team would consider this an enhancement request rather than a defect.

You are likely to get what you want faster either by writing your own version of print-table that works as you wish, or see whether these projects already behave as desired, or the authors are willing to enhance them: https://github.com/cldwalker/table or https://github.com/joegallo/doric

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1230 (reported by alex+import)
...