Clojure

print-table displays tables incorrectly when one of the cells is a string that has newlines

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Mac OS X, Clojure 1.5.1

Description

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

Activity

Andy Fingerhut made changes -
Field Original Value New Value
Description 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
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:

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

| :a | :b |
|------+------------|
| test | test
test2 |
nil
{noformat}

I would expect the output to look something like this:

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

| :a | :b |
|------+------------|
| test | test +
| | test2 |
nil
{noformat}

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:

{noformat}
user=# select 'test' col1, E'test\ntest2\ntest3' col2;
 col1 | col2
------+-------
 test | test +
      | test2+
      | test3
(1 row)

Time: 0.776 ms
{noformat}
Alex Miller made changes -
Labels print
Stuart Halloway made changes -
Priority Major [ 3 ] Minor [ 4 ]
Issue Type Defect [ 1 ] Enhancement [ 4 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: