Re: printing table in asciidoc with psql

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Szymon Guz <mabewlun(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: printing table in asciidoc with psql
Date: 2014-12-03 06:52:30
Message-ID: CAB7nPqTtBPOOGi-3ELt9uFJT16HHy-ksSwQd+4WpAYXbzymcOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 17, 2014 at 7:48 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2014-11-07 22:37 GMT+01:00 Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>:
>>
>>
>> I did \o /tmp/tst, then
>> \dS
>> create table "eh | oh" ();
>> \dS
>>
>> and then filtered the output file to HTML. The CREATE TABLE tag ended
>> up in the same line as the title of the following table. I think
>> there's a newline is missing somewhere.
>>
>>
>> The good news is that the | in the table name was processed correctly;
>> but I noticed that the table title is not using the escaped print, so I
>> would imagine that if I put a | in the title, things would go wrong.
>> (I don't know how to put titles on tables other than editing the
>> hardcoded titles for \ commands in psql).
>>
>> Another thing is that spaces around the | seem gratuituous and produce
>> bad results. I tried "select * from pg_class" which results in a very
>> wide table, and then the HTML output contains some cells with the values
>> in the second line; this makes all rows taller than they must be,
>> because some cells use the first line and other cells in the same row
>> use the second line for the text. I hand-edited the asciidoc and
>> removed the spaces around | which makes the result nicer. (Maybe
>> removing the trailing space is enough.)
>
>
> I see a trailing spaces, but I don't see a described effect. Please, can you
> send some more specific test case?

This formatting problem is trivial to reproduce:
=# create table "foo" ();

CREATE TABLE
Time: 9.826 ms
=# \d

.List of relations
[options="header",cols="<l,<l,
<l,<l",frame="none"]
|====
^l| Schema ^l| Name ^l| Type ^l| Owner
| public | foo | table | ioltas
|====

....
(1 row)
....

I just tested this patch, and yes I agree with Alvaro that it would be
good to minimize the extra spaces around the table separators '|'. Now
we need to be careful as well, and I think that we should just remove
the separators on the right of the separators as cells values
controlling for example spans would result in incorrect output, stuff
like that:
5 2.2+^.^
9 2+>

Also, something a bit surprising is that this format produces always
one newline for each command, for example in the case of a DDL:
=# create table foo ();

CREATE TABLE
I think that this extra space should be removed as well, no?

This patch has been marked as "Waiting on Author" for a couple of
weeks, and the problems mentioned before have not been completely
addressed, hence marking this patch as returned with feedback. It
would be nice to see progress for the next CF.
Regards,
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-12-03 06:53:29 Re: printing table in asciidoc with psql
Previous Message Kouhei Kaigai 2014-12-03 06:23:28 Re: using custom scan nodes to prototype parallel sequential scan