Re: printing table in asciidoc with psql - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: printing table in asciidoc with psql
Date
Msg-id 20150323234435.GB11352@momjian.us
Whole thread Raw
In response to Re: printing table in asciidoc with psql  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: printing table in asciidoc with psql
List pgsql-hackers
On Sun, Mar 22, 2015 at 08:06:17PM +0900, Michael Paquier wrote:
> > I have updated the attached patch to do as you suggested.  Please also
> > test the \x output.  Thanks.
>
> Indeed. If I use a specific column name like this one, I am seeing
> problems with the expanded mode:
> =# create table "5 2.2+^.^" ("5 2.2+^.^" int);
> CREATE TABLE
> =# \x
> Expanded display is on.
> =# INSERT INTO "5 2.2+^.^" VALUES (1);
> INSERT 0 1
> =# table "5 2.2+^.^";
>
> [cols="h,l",frame="none"]
> |====
> 2+^|Record 1
> <|5 2.2+^.^ >|1
> |====
>
> In this case the record is printed like that:
> 5 2.2+.
> While it should show up like that:
> 5 2.2+^.^

OK, fixed.  It turns out you need to specify the style on each output
row ('l'/literal) so that a later data value of ^.^ is not intepreted as
a horizontal/vertial alignment specification.  (Wow, it sounds like I
know what I am talking about.  ;-) )

The new output is:

    test=> \pset format asciidoc
    Output format is asciidoc.
    test=> \x
    Expanded display is on.
    test=> table "5 2.2+^.^";

    [cols="h,l",frame="none"]
    |====
    2+^|Record 1
-->    <l|5 2.2+^.^ >|1
    |====

Notice the added 'l' next to the '<'.  Updated patch attached.  Any
other issues?

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Abbreviated keys for Numeric
Next
From: Robert Haas
Date:
Subject: Re: Abbreviated keys for Numeric