Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-09-18 Thread Jan Michálek
Thanks

2017-09-18 15:33 GMT+02:00 Daniel Gustafsson <dan...@yesql.se>:

> > On 18 Sep 2017, at 15:31, Jan Michálek <godzilalal...@gmail.com> wrote:
> >
> > I have`t any new version recently, because i was waiting for new
> version. But I will have some time on this in next months. How many time I
> have to next freeze?
>
> The next commitfest runs from 2017-11-01 to 2017-11-30, I will move your
> patch
> there.
>
> cheers ./daniel




-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-09-18 Thread Jan Michálek
I have`t any new version recently, because i was waiting for new version.
But I will have some time on this in next months. How many time I have to
next freeze?

Thanks Je;

2017-09-13 1:14 GMT+02:00 Daniel Gustafsson <dan...@yesql.se>:

> > On 08 May 2017, at 12:02, Fabien COELHO <fabien.coelho@mines-
> paristech.fr> wrote:
> >
> > Hello Jan,
> >
> > Please give a number to submitted patches. I think that this was v3.
> >
> > The patch does NOT fix various issues I pointed out in my previous
> review:
> >
> > - tabs introduced in "doc/src/sgml/ref/psql-ref.sgml"
> > - too long help line in "src/bin/psql/help.c"
> > - spurious space after a comma in "src/fe_utils/print.c"
> >   and possibly elsewhere.
> >
> > On Sun, 23 Apr 2017, Jan Michálek wrote:
> >
> >>>> Markdown include characters/sequences which are interpreted as
> markers:
> >>>> _Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
> >>>> code`... If they are interpreted within a table cell then probably
> they
> >>>> should be escaped somehow.
> >>
> >> I have treated "_*|<>"
> >
> > Probably not enough, see below. Note the escaping chars should also be
> escaped.
> >
> >>> I`m able to sanitize characters, but complex sequences will be
> problem. I
> >>> will look on this, but I don`t know, if I`m able to do this.
> >
> > I do not know whether only those are necessary. Have you checked?
> Guessing is probably not the right approach.
> >
> >
> > Concerning MARKDOWN, and according to the following source about github
> markdown implementation:
> >
> >   https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf
> >
> > The following characters may need to be backslash escaped, although it
> does not cover HTML stuff.
> >
> >   \   backslash
> >   `   backtick
> >   *   asterisk
> >   _   underscore
> >   {}  curly braces
> >   []  square brackets
> >   ()  parentheses
> >   #   hash mark
> >   +   plus sign
> >   -   minus sign (hyphen)
> >   .   dot
> >   !   exclamation
> >
> > Another source https://genius.com/3057216 suggests (* # / ( ) [ ] < >),
> > which should protect HTML.
> >
> > However, the escaping seems to be the backslash character, NOT using
> html encoding  as done in your version.
> >
> > Where did you find the precise escaping rules for markdown? I do not
> think that it should be invented...
> >
> >
> > I have looked at RST, according to this reference:
> >
> >   http://docutils.sourceforge.net/docs/ref/rst/
> restructuredtext.html#grid-tables
> >
> > The good news is that you do not need to handle a special | case because
> you would only produce clean tables.
> >
> > I've tested UTF-8 with plane 1 (你好!) and plane 2 (!) and the alignment
> seems to worked well, incredible!
> >
> >>> My main interest on this was in rst. I`m using markdown only in github
> issues and my knowldge about md is poor.
> >
> > Then maybe only do RST?!
> >
> > It looks much simpler anyway, and if you do MARKDOWN the support needs
> to be clean.
> >
> > About the code:
> >
> > I'm still at odds with the code which needs to test for markdown to call
> for different functions in multiple places. If you keep md and in order to
> avoid that, I would suggest to extend the pg_wcs* functions with a list of
> caracters which may have different sizes with additionnal args, say:
> >
> >  pg_wcssize(// same args, plus:
> > char * escaped_chars, // will require escaping
> > int escape_len, // how many chars added when escaping
> > int nllen // len of newline if substituted
> > );
> >
> > So that pg_wcssize(..., "\r", 1, 1) would behave as before (\n and \t
> are rather special cases), and the various constants could be held in the
> format description so the whole thing would be parametric.
> >
> > Same approach with format.
> >
> > That would allow to simplify the code significantly and to share it
> between MARKDOWN and others. Also, the multiple "else if" list would be
> simplified by using strchr or the escaped_chars string.
>
> This patch was moved into the current Commitfest marked “Waiting for
> author”
> with the above review.  Have you had a chance to work on it addressing the
> review comments such that we can expect a new version within this CF?
>
> cheers ./daniel




-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-23 Thread Jan Michálek
2017-04-19 10:05 GMT+02:00 Jan Michálek <godzilalal...@gmail.com>:

> 2017-04-19 9:18 GMT+02:00 Fabien COELHO <coe...@cri.ensmp.fr>:
>
>>
>> I still do not understand "why" this variant vs CommonMark or whatever
>>>> other version.
>>>>
>>>
>>> Because of simply implementation and readability (looks similar to
>>> aligned
>>> format) and it is comfortable to edit generated table (changing values,
>>> aligning columns etc.).
>>>
>>
>> Hmmm. Why not.
>>
>> Sorry, maybe I`m not understanding, there is problems with characters like
>>> pipe in cells, pipe should be escaped. What other special markdown
>>> characters? Escaping html code in cells?
>>>
>>
>> Markdown include characters/sequences which are interpreted as markers:
>> _Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
>> code`... If they are interpreted within a table cell then probably they
>> should be escaped somehow.
>>
>
>
I have treated "_*|<>"

jelen=# SELECT E'**1**\nrrr';
| **RECORD 1** |  |
|--|--|
| ?column? | \*\*1\*\*/b |


jelen=#

> I`m able to sanitize characters, but complex sequences will be problem. I
> will look on this, but I don`t know, if I`m able to do this.
>
> My main interest on this was in rst. I`m using markdown only in github
> issues and my knowldge about md is poor.
>
>
>>
>> Main of the functionality is used from aligned format. I tested returned
>>>>> tables in retext and it works. If i have another character than
>>>>> standart
>>>>> pipe, it shouldn`t work.
>>>>>
>>>>> Sure. ISTM that you are currently using U+2502 instead of pipe, hence
>>>> my
>>>> point.
>>>>
>>>
>>> Could you send me example where?
>>>
>>
>> I already did in the first mail with the example output copy pasted from
>> psql. Some characters are pipe and others are BOX DRAWINGS LIGHT VERTICAL
>> characters.
>>
>> Maybe this is because I have in my ~/.psqlrc:
>>
>>  \pset linestyle unicode
>>  \pset border 2
>>
>
>> in which case your reuse of the the aligned stuff should take care of the
>> border setting to avoid using special UTF8 characters..
>>
>
I corrected it.

jelen=# \pset linestyle unicode
Line style is unicode.
jelen=# SELECT 1,2,3,4;
| **RECORD 1** |   |
|--|---|
| ?column? | 1 |
| ?column? | 2 |
| ?column? | 3 |
| ?column? | 4 |


jelen=#

Regards
Jan



>
> Yes, it looks it is done by linestyle.
>
>
> jelen=# SELECT 1;
>
> | ?column? |
> |--|
> |1 |
>
>
> (1 row)
>
> jelen=# \pset linestyle unicode
> Line style is unicode.
> jelen=# SELECT 1;
>
> │ ?column? │
> |--|
> │1 │
>
>
> (1 row)
>
> jelen=#
>
> I have prepared linestyle for rst and md, but I can`t switch linestyle
> outside, because if i did it
> \pset linestyle
> wrote "markdown" or "rst".
> I see, problem is only in cells borders, I will correct this.
>
> Jan
>
>
>>
>> --
>> Fabien.
>>
>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 3b86612862..97d8612359 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***
*** 2536,2542  lo_import 152801
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
!   latex-longtable, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
--- 2536,2543 
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
! 		  latex-longtable, 
! 		  rst, markdown, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
***
*** 2564,2570  lo_import 152801
  

The html, asciidoc, latex,
!   latex-longtable, and troff-ms
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2565,2572 
  

The html, asciidoc, latex,
! 		  latex-longtable, troff-ms,
! 		  markdown and rst
formats put out tables that are intended to
be i

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-19 Thread Jan Michálek
2017-04-19 9:18 GMT+02:00 Fabien COELHO :

>
> I still do not understand "why" this variant vs CommonMark or whatever
>>> other version.
>>>
>>
>> Because of simply implementation and readability (looks similar to aligned
>> format) and it is comfortable to edit generated table (changing values,
>> aligning columns etc.).
>>
>
> Hmmm. Why not.
>
> Sorry, maybe I`m not understanding, there is problems with characters like
>> pipe in cells, pipe should be escaped. What other special markdown
>> characters? Escaping html code in cells?
>>
>
> Markdown include characters/sequences which are interpreted as markers:
> _Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
> code`... If they are interpreted within a table cell then probably they
> should be escaped somehow.
>

I`m able to sanitize characters, but complex sequences will be problem. I
will look on this, but I don`t know, if I`m able to do this.

My main interest on this was in rst. I`m using markdown only in github
issues and my knowldge about md is poor.


>
> Main of the functionality is used from aligned format. I tested returned
 tables in retext and it works. If i have another character than standart
 pipe, it shouldn`t work.

 Sure. ISTM that you are currently using U+2502 instead of pipe, hence my
>>> point.
>>>
>>
>> Could you send me example where?
>>
>
> I already did in the first mail with the example output copy pasted from
> psql. Some characters are pipe and others are BOX DRAWINGS LIGHT VERTICAL
> characters.
>
> Maybe this is because I have in my ~/.psqlrc:
>
>  \pset linestyle unicode
>  \pset border 2
>
> in which case your reuse of the the aligned stuff should take care of the
> border setting to avoid using special UTF8 characters..
>

Yes, it looks it is done by linestyle.


jelen=# SELECT 1;

| ?column? |
|--|
|1 |


(1 row)

jelen=# \pset linestyle unicode
Line style is unicode.
jelen=# SELECT 1;

│ ?column? │
|--|
│1 │


(1 row)

jelen=#

I have prepared linestyle for rst and md, but I can`t switch linestyle
outside, because if i did it
\pset linestyle
wrote "markdown" or "rst".
I see, problem is only in cells borders, I will correct this.

Jan


>
> --
> Fabien.
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-19 Thread Jan Michálek
2017-04-18 23:06 GMT+02:00 Fabien COELHO :

>
> Hello,
>
> There are different flavour of markdown, maybe you should document which
>>> one is targetted. Should it be CommonMark? Another variant? Why?
>>>
>>
>> This should be pandoc pipe table. It's because it is similar to aligned
>> format. I need add this to documentation (i have it in recent TODO)
>>
>
> I still do not understand "why" this variant vs CommonMark or whatever
> other version.
>

Because of simply implementation and readability (looks similar to aligned
format) and it is comfortable to edit generated table (changing values,
aligning columns etc.).


>
> ISTM that the md format lacks escaping for special md characters [...] I'd
>>> say that you need to do escaping more or less similar to html?
>>>
>>
>> There is problem with markown and newlines. Replacing newline by br was
>> only solution that I was able to find.
>>
>
> Fine. That does not answer the question about escaping other special md
> characters.
>

Sorry, maybe I`m not understanding, there is problems with characters like
pipe in cells, pipe should be escaped. What other special markdown
characters? Escaping html code in cells?


>
> Also, it seems that you use distinct vertical bar characters in the
>>> format? Or is this a trick of my terminal?? It seems that your patch
>>> introduces U+2502 (BOX DRAWINGS LIGHT VERTICAL) instead of the usual pipe
>>> in some places. Maybe you copy-pasted things from the unicode linestyle.
>>>
>>
>> Main of the functionality is used from aligned format. I tested returned
>> tables in retext and it works. If i have another character than standart
>> pipe, it shouldn`t work.
>>
>
> Sure. ISTM that you are currently using U+2502 instead of pipe, hence my
> point.
>

Could you send me example where?


>
> Why are *_newline variants added for length and formatting? Would it be
>>> possible to do without, say by relying on the line count computed by the
>>> standard function for instance?
>>>
>>
>> It`s because newlines in markdown, If I need to do it without copy this
>> function, i had to add parameter for markdown to this functions.
>>
>
> Then maybe it is an option to consider to avoid duplicating code.
>
> --
> Fabien.
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-18 Thread Jan Michálek
2017-04-18 12:06 GMT+02:00 Fabien COELHO :

>
> Hello Jan,
>
> It seems that the patch does not apply anymore on head due to changes in
>>> psql non regression tests. Could you rebase?
>>>
>>
>> This should work on current master (all test passed).
>>
>
> Patch applies, compiles and make check is ok.
>
> There are different flavour of markdown, maybe you should document which
> one is targetted. Should it be CommonMark? Another variant? Why?
>

This should be pandoc pipe table. It's because it is similar to aligned
format. I need add this to documentation (i have it in recent TODO)


>
> ISTM that the md format lacks escaping for special md characters:
>
>  fabien=# SELECT E'\\n\n' AS foo;
>  │ foo  │
>  |--|
>  │ \n
>
> I'd say that you need to do escaping more or less similar to html?
>

There is problem with markown and newlines. Replacing newline by br was
only solution that I was able to find.

>
> Also, it seems that you use distinct vertical bar characters in the
> format? Or is this a trick of my terminal?? It seems that your patch
> introduces U+2502 (BOX DRAWINGS LIGHT VERTICAL) instead of the usual pipe
> in some places. Maybe you copy-pasted things from the unicode linestyle.
>

Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than standart
pipe, it shouldn`t work.


>
> Why are *_newline variants added for length and formatting? Would it be
> possible to do without, say by relying on the line count computed by the
> standard function for instance?
>

It`s because newlines in markdown, If I need to do it without copy this
function, i had to add parameter for markdown to this functions.


>
> The help line is too long, I would suggest not to add the new formats, the
> list is already truncated with "..." for other formats.
>

OK


>
> In the sgml documentation, you introduce tab characters, where only spaces
> should be used.
>

OK, I modified vimrc as it is in documentation, maybe i do something wrong.
I will correct this.


>
> pg_markdown obsahuje falešný prostor mezi čárkou a nový řádek.
>

I will look on this.


>
> --
> Fabien.




-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-18 Thread Jan Michálek
2017-04-18 2:27 GMT+02:00 Fabien COELHO :

>
> Hello Jan,
>
> Corrected problem with \pset linestyle when format is set to markdown, or
>> rst.
>>
>> Corrected tuples only for markdown and rst (normal and expanded)
>>
>
> It seems that the patch does not apply anymore on head due to changes in
> psql non regression tests. Could you rebase?
>

This should work on current master (all test passed).

Je;


>
> --
> Fabien.
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 3b86612862..97d8612359 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***
*** 2536,2542  lo_import 152801
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
!   latex-longtable, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
--- 2536,2543 
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
! 		  latex-longtable, 
! 		  rst, markdown, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
***
*** 2564,2570  lo_import 152801
  

The html, asciidoc, latex,
!   latex-longtable, and troff-ms
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2565,2572 
  

The html, asciidoc, latex,
! 		  latex-longtable, troff-ms,
! 		  markdown and rst
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 859ded71f6..5bca425d22 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***
*** 3693,3698  _align2string(enum printFormat in)
--- 3693,3704 
  		case PRINT_TROFF_MS:
  			return "troff-ms";
  			break;
+ 		case PRINT_MARKDOWN:
+ 			return "markdown";
+ 			break;
+ 		case PRINT_RST:
+ 			return "rst";
+ 			break;
  	}
  	return "unknown";
  }
***
*** 3764,3772  do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
  			popt->topt.format = PRINT_LATEX_LONGTABLE;
  		else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
  			popt->topt.format = PRINT_TROFF_MS;
  		else
  		{
! 			psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
  			return false;
  		}
  	}
--- 3770,3782 
  			popt->topt.format = PRINT_LATEX_LONGTABLE;
  		else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
  			popt->topt.format = PRINT_TROFF_MS;
+ 		else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ 			popt->topt.format = PRINT_MARKDOWN;
+ 		else if (pg_strncasecmp("rst", value, vallen) == 0)
+ 			popt->topt.format = PRINT_RST;
  		else
  		{
! 			psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
  			return false;
  		}
  	}
diff --git a/src/bin/psql/helindex ac435220e6..13f2e44add 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***
*** 382,388  helpVariables(unsigned short int pager)
  	fprintf(output, _("  fieldsep   field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
  	fprintf(output, _("  fieldsep_zero  set field separator for unaligned output to zero byte\n"));
  	fprintf(output, _("  footer enable or disable display of the table footer [on, off]\n"));
! 	fprintf(output, _("  format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
  	fprintf(output, _("  linestyle  set the border line drawing style [ascii, old-ascii, unicode]\n"));
  	fprintf(output, _("  null   set the string to be printed in place of a null value\n"));
  	fprintf(output, _("  numericlocale  enable or disable display of a locale-specific character to separate\n"
--- 382,388 
  	fprintf(output, _("  fieldsep   field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
  	fprintf(output, _("  fieldsep_zero  set field separator for unaligned output to zero byte\n"));
  	fprintf(output, _("  footer enable or disable display of the table footer [on, off]\n"));
! 	fprintf(output, _("  format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
  	fprintf(output, _("  linestyle  set the border line drawing style [ascii, old-ascii, unicode]\n"));
  	fprintf(output, _("  null   set the string to be printed in place of a null value\n"));
  	

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-18 Thread Jan Michálek
2017-04-18 2:27 GMT+02:00 Fabien COELHO :

>
> Hello Jan,
>
> Corrected problem with \pset linestyle when format is set to markdown, or
>> rst.
>>
>> Corrected tuples only for markdown and rst (normal and expanded)
>>
>
> It seems that the patch does not apply anymore on head due to changes in
> psql non regression tests. Could you rebase?
>

Hi
This patch willl not be in 10, because i haven`t it already completed on
commit freeze.

Should I update it to current master? Im afraid, that some changes will be
in conflict with this.

Je;



>
> --
> Fabien.
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-06 Thread Jan Michálek
2017-04-06 0:55 GMT+02:00 Andres Freund <and...@anarazel.de>:

> Hi,
>
> On 2017-04-02 22:28:40 +0200, Jan Michálek wrote:
> > 2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.p...@pinaraf.info>:
> > > The new status of this patch is: Waiting on Author
> > >
> >
> > Corrected problem with \pset linestyle when format is set to markdown, or
> > rst.
> >
> > Corrected tuples only for markdown and rst (normal and expanded)
>
> This patch still is undergoing development and review, and the code
> freeze is closing in rapidly.  As this patch has been submitted just
> before the last commitfest in the v10 cycle and has received plenty
> feedback, I think it's fair to move this to the next commitfest.
>
> Regards,
>
> Andres
>
There is only few last things to complete (align by |:- in markdown and
pset title, and few words about pabdoc pipe tables in documentation).
I hope, I`m able to do this on sunday, or monday.

Jan


-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-04-02 Thread Jan Michálek
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet :

> The following review has been posted through the commitfest application:
> make installcheck-world:  tested, passed
> Implements feature:   tested, passed
> Spec compliant:   tested, passed
> Documentation:tested, passed
>
> Hi
>
> This is my first review (Magnus said in his presentation in PGDay Paris
> that volunteers should just come and help, so here I am), so please notify
> me for any mistake I do when using the review tools...
>
> The feature seems to work as expected, but I don't claim to be a markdown
> and rst expert.
> Some minor issues with the code itself :
> - some indentation issues (documentation and code itself with mix between
> space based and tab based indentation) and a few trailing spaces in code
> - typographic issues in the documentation :
>   - "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
> and rst formats" ==> duplicated and
>   - "Sets the output format to one of unaligned, aligned, wrapped, html,
> asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
> troff-ms." ==> extra comma at the end of the list
> - the comment " dont add line after last row, because line is added after
> every row" is misleading, it should warn that it's only for rst
> - there is a block of commented out code left
> - in the print_aligned_vertical function, there is a mix between
> "cont->opt->format == PRINT_RST" and "format == _rst" and I don't see
> any obvious reason for that
> - the documentation doesn't mention (but ok, it's kind of obvious) that
> the linestyle option will not work with rst and markdown
>
> Thanks !
>
> The new status of this patch is: Waiting on Author
>

Corrected problem with \pset linestyle when format is set to markdown, or
rst.

Corrected tuples only for markdown and rst (normal and expanded)

Jan



>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index ad463e71c1..b513aa703b 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***
*** 2470,2476  lo_import 152801
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
!   latex-longtable, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
--- 2470,2477 
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
! 		  latex-longtable, 
! 		  rst, markdown, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
***
*** 2498,2504  lo_import 152801
  

The html, asciidoc, latex,
!   latex-longtable, and troff-ms
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2499,2506 
  

The html, asciidoc, latex,
! 		  latex-longtable, troff-ms,
! 		  markdown and rst
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 94a3cfce90..9b5c4c9eec 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***
*** 3684,3689  _align2string(enum printFormat in)
--- 3684,3695 
  		case PRINT_TROFF_MS:
  			return "troff-ms";
  			break;
+ 		case PRINT_MARKDOWN:
+ 			return "markdown";
+ 			break;
+ 		case PRINT_RST:
+ 			return "rst";
+ 			break;
  	}
  	return "unknown";
  }
***
*** 3755,3763  do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
  			popt->topt.format = PRINT_LATEX_LONGTABLE;
  		else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
  			popt->topt.format = PRINT_TROFF_MS;
  		else
  		{
! 			psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
  			return false;
  		}
  	}
--- 3761,3773 
  			popt->topt.format = PRINT_LATEX_LONGTABLE;
  		else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
  			popt->topt.format = PRINT_TROFF_MS;
+ 		else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ 			popt->topt.format = PRINT_MARKDOWN;
+ 		else if (pg_strncasecmp("rst", value, vallen) == 0)
+ 			popt->topt.format = PRINT_RST;
  		else
  		{
! 			psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
  			return false;
  		}
  	}
diff --git a/src/bin/psql/helindex 

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-31 Thread Jan Michálek
2017-03-31 12:01 GMT+02:00 Pierre Ducroquet <p@pinaraf.info>:

> On Friday, March 31, 2017 7:17:08 AM CEST, Jan Michálek wrote:
>
>>
>>
>> 2017-03-30 21:53 GMT+02:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>
>>
>> 2017-03-29 20:11 GMT+02:00 Jan Michálek <godzilalal...@gmail.com>:
>>
>>
>> 2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalal...@gmail.com>:
>>
>>
>> 2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.p...@pinaraf.info>:
>> The following review has been posted through the commitfest application:
>> make installcheck-world:  tested, passed
>> Implements feature:   tested, passed
>> Spec compliant:   tested, passed
>> Documentation:tested, passed
>>
>> Hi
>>
>> This is my first review (Magnus said in his presentation in PGDay Paris
>> that volunteers should just come and help, so here I am), so please notify
>> me for any mistake I do when using the review tools...
>>
>> The feature seems to work as expected, but I don't claim to be a markdown
>> and rst expert.
>> Some minor issues with the code itself :
>> - some indentation issues (documentation and code itself with mix between
>> space based and tab based indentation) and a few trailing spaces in code
>>
>> corrected
>>  - typographic issues in the documentation :
>>   - "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
>> and rst formats" ==> duplicated and
>>
>> corrected   - "Sets the output format to one of unaligned, aligned,
>> wrapped, html, asciidoc, latex (uses tabular), latex-longtable, rst,
>> markdown, or troff-ms." ==> extra comma at the end of the list
>> - the comment " dont add line after last row, because line is added after
>> every row" is misleading, it should warn that it's only for rst
>> - there is a block of commented out code left
>> - in the print_aligned_vertical function, there is a mix between
>> "cont->opt->format == PRINT_RST" and "format == _rst" and I don't see
>> any obvious reason for that
>> corrected - the documentation doesn't mention (but ok, it's kind of
>> obvious) that the linestyle option will not work with rst and markdown
>>
>>
>> In this patch are corrected (i hope, i had correct changes in vimrc)
>> indentation issues. Plese, look at this if it is OK (i men indentats) and
>> some minor errors. And it should work on current master (probably).
>>
>> Added \x option form markdown
>> In markdown works multiline cels (newline replaced by )
>> regre tests passed
>>
>> \pset format rst
>> \x
>> select 10
>> crash on segfault
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x7f77673a866c in vfprintf () from /lib64/libc.so.6
>> (gdb) bt
>> #0  0x7f77673a866c in vfprintf () from /lib64/libc.so.6
>> #1  0x7f77673b1574 in fprintf () from /lib64/libc.so.6
>> #2  0x00437bc5 in print_aligned_vertical (cont=0x7fffade43da0,
>> fout=, is_pager=) at print.c:1755
>> #3  0x0043a70d in printTable (cont=cont@entry=0x7fffade43da0,
>> fout=, fout@entry=0x7f77677255e0 <_IO_2_1_stdout_>,
>> is_pager=, is_pager@entry=0 '\000', flog=flog@entry=0x0)
>> at print.c:3466
>> #4  0x0043c37f in printQuery (result=result@entry=0x9c4b60,
>> opt=opt@entry=0x7fffade43f00, fout=0x7f77677255e0 <_IO_2_1_stdout_>,
>> is_pager=is_pager@entry=0 '\000', flog=0x0) at print.c:3551
>> #5  0x0040da6d in PrintQueryTuples (results=0x9c4b60) at
>> common.c:808
>> #6  PrintQueryResults (results=0x9c4b60) at common.c:1140
>> #7  SendQuery (query=0x9c1700 "select 10;") at common.c:1317
>> #8  0x0041c3d4 in MainLoop (source=0x7f77677248a0
>> <_IO_2_1_stdin_>) at mainloop.c:319
>> #9  0x00405d5d in main (argc=, argv=> out>) at startup.c:396
>>
>> Regards
>>
>> On source from monday it works (last commit on master I have is from 27.3
>> 14:30). Or, maybe I didn`t generate diff well, or some gitt issue.
>>
>
> I agree with Pavel, there is a segfault when you do these with your
> current patch. The current patch does not pass make check-world.
> How did you generate the diff ? Basically, the simplest way to generate a
> patch serie is through git format-patch.
> For instance, say you have a rstFormat branch freshly rebased upon
> origin/master, just do git format-patch origin/master..rstFormat and you
> will have one patch file per commit.
>

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-30 Thread Jan Michálek
2017-03-30 21:53 GMT+02:00 Pavel Stehule <pavel.steh...@gmail.com>:

>
>
> 2017-03-29 20:11 GMT+02:00 Jan Michálek <godzilalal...@gmail.com>:
>
>>
>>
>> 2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalal...@gmail.com>:
>>
>>>
>>>
>>> 2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.p...@pinaraf.info>:
>>>
>>>> The following review has been posted through the commitfest application:
>>>> make installcheck-world:  tested, passed
>>>> Implements feature:   tested, passed
>>>> Spec compliant:   tested, passed
>>>> Documentation:tested, passed
>>>>
>>>> Hi
>>>>
>>>> This is my first review (Magnus said in his presentation in PGDay Paris
>>>> that volunteers should just come and help, so here I am), so please notify
>>>> me for any mistake I do when using the review tools...
>>>>
>>>> The feature seems to work as expected, but I don't claim to be a
>>>> markdown and rst expert.
>>>> Some minor issues with the code itself :
>>>> - some indentation issues (documentation and code itself with mix
>>>> between space based and tab based indentation) and a few trailing spaces in
>>>> code
>>>>
>>>
>>> corrected
>>>
>>>
>>>> - typographic issues in the documentation :
>>>>   - "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
>>>> and rst formats" ==> duplicated and
>>>>
>>>
>>> corrected
>>>
>>>>   - "Sets the output format to one of unaligned, aligned, wrapped,
>>>> html, asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
>>>> troff-ms." ==> extra comma at the end of the list
>>>> - the comment " dont add line after last row, because line is added
>>>> after every row" is misleading, it should warn that it's only for rst
>>>> - there is a block of commented out code left
>>>> - in the print_aligned_vertical function, there is a mix between
>>>> "cont->opt->format == PRINT_RST" and "format == _rst" and I don't see
>>>> any obvious reason for that
>>>>
>>> corrected
>>>
>>>> - the documentation doesn't mention (but ok, it's kind of obvious) that
>>>> the linestyle option will not work with rst and markdown
>>>>
>>>>
>>> In this patch are corrected (i hope, i had correct changes in vimrc)
>>> indentation issues. Plese, look at this if it is OK (i men indentats) and
>>> some minor errors. And it should work on current master (probably).
>>>
>>
>> Added \x option form markdown
>> In markdown works multiline cels (newline replaced by )
>> regre tests passed
>>
>
> \pset format rst
> \x
> select 10
> crash on segfault
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x7f77673a866c in vfprintf () from /lib64/libc.so.6
> (gdb) bt
> #0  0x7f77673a866c in vfprintf () from /lib64/libc.so.6
> #1  0x7f77673b1574 in fprintf () from /lib64/libc.so.6
> #2  0x00437bc5 in print_aligned_vertical (cont=0x7fffade43da0,
> fout=,
> is_pager=) at print.c:1755
> #3  0x0043a70d in printTable (cont=cont@entry=0x7fffade43da0,
> fout=,
> fout@entry=0x7f77677255e0 <_IO_2_1_stdout_>, is_pager= out>, is_pager@entry=0 '\000',
> flog=flog@entry=0x0) at print.c:3466
> #4  0x0043c37f in printQuery (result=result@entry=0x9c4b60,
> opt=opt@entry=0x7fffade43f00,
> fout=0x7f77677255e0 <_IO_2_1_stdout_>, is_pager=is_pager@entry=0
> '\000', flog=0x0) at print.c:3551
> #5  0x0040da6d in PrintQueryTuples (results=0x9c4b60) at
> common.c:808
> #6  PrintQueryResults (results=0x9c4b60) at common.c:1140
> #7  SendQuery (query=0x9c1700 "select 10;") at common.c:1317
> #8  0x0041c3d4 in MainLoop (source=0x7f77677248a0
> <_IO_2_1_stdin_>) at mainloop.c:319
> #9  0x00405d5d in main (argc=, argv= out>) at startup.c:396
>
> Regards
>

On source from monday it works (last commit on master I have is from 27.3
14:30). Or, maybe I didn`t generate diff well, or some gitt issue.

psql (10devel, server 9.6.1)
Type "help" for help.

jelen=# \x
Expanded display is on.
jelen=# \pset format rst
Output format is rst.
jelen=# select 10;
+--++
| **RECORD 1**  |
+--++
| **?column?** | 10 |
+--++

jelen=#



>
> Pavel
>
>
>>
>>
>> Jan
>>
>>
>>
>>>
>>> Have nice day
>>>
>>> Jan
>>>
>>>
>>>> Thanks !
>>>>
>>>> The new status of this patch is: Waiting on Author
>>>>
>>>> --
>>>> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgsql-hackers
>>>>
>>>
>>>
>>>
>>> --
>>> Jelen
>>> Starší čeledín datovýho chlíva
>>>
>>
>>
>>
>> --
>> Jelen
>> Starší čeledín datovýho chlíva
>>
>>
>> --
>> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-hackers
>>
>>
>


-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-29 Thread Jan Michálek
2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalal...@gmail.com>:

>
>
> 2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.p...@pinaraf.info>:
>
>> The following review has been posted through the commitfest application:
>> make installcheck-world:  tested, passed
>> Implements feature:   tested, passed
>> Spec compliant:   tested, passed
>> Documentation:tested, passed
>>
>> Hi
>>
>> This is my first review (Magnus said in his presentation in PGDay Paris
>> that volunteers should just come and help, so here I am), so please notify
>> me for any mistake I do when using the review tools...
>>
>> The feature seems to work as expected, but I don't claim to be a markdown
>> and rst expert.
>> Some minor issues with the code itself :
>> - some indentation issues (documentation and code itself with mix between
>> space based and tab based indentation) and a few trailing spaces in code
>>
>
> corrected
>
>
>> - typographic issues in the documentation :
>>   - "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
>> and rst formats" ==> duplicated and
>>
>
> corrected
>
>>   - "Sets the output format to one of unaligned, aligned, wrapped, html,
>> asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
>> troff-ms." ==> extra comma at the end of the list
>> - the comment " dont add line after last row, because line is added after
>> every row" is misleading, it should warn that it's only for rst
>> - there is a block of commented out code left
>> - in the print_aligned_vertical function, there is a mix between
>> "cont->opt->format == PRINT_RST" and "format == _rst" and I don't see
>> any obvious reason for that
>>
> corrected
>
>> - the documentation doesn't mention (but ok, it's kind of obvious) that
>> the linestyle option will not work with rst and markdown
>>
>>
> In this patch are corrected (i hope, i had correct changes in vimrc)
> indentation issues. Plese, look at this if it is OK (i men indentats) and
> some minor errors. And it should work on current master (probably).
>

Added \x option form markdown
In markdown works multiline cels (newline replaced by )
regre tests passed

Jan



>
> Have nice day
>
> Jan
>
>
>> Thanks !
>>
>> The new status of this patch is: Waiting on Author
>>
>> --
>> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-hackers
>>
>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 2a9c412020..ee0c8fbea6 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***
*** 2366,2372  lo_import 152801
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
!   latex-longtable, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
--- 2366,2373 
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
! 		  latex-longtable, 
! 		  rst, markdown, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
***
*** 2394,2400  lo_import 152801
  

The html, asciidoc, latex,
!   latex-longtable, and troff-ms
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2395,2402 
  

The html, asciidoc, latex,
! 		  latex-longtable, troff-ms,
! 		  markdown and rst
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 4f4a0aa9bd..97f4f37923 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***
*** 2518,2523  _align2string(enum printFormat in)
--- 2518,2529 
  		case PRINT_TROFF_MS:
  			return "troff-ms";
  			break;
+ 		case PRINT_MARKDOWN:
+ 			return "markdown";
+ 			break;
+ 		case PRINT_RST:
+ 			return "rst";
+ 			break;
  	}
  	return "unknown";
  }
***
*** 2589,2597  do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-27 Thread Jan Michálek
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet :

> The following review has been posted through the commitfest application:
> make installcheck-world:  tested, passed
> Implements feature:   tested, passed
> Spec compliant:   tested, passed
> Documentation:tested, passed
>
> Hi
>
> This is my first review (Magnus said in his presentation in PGDay Paris
> that volunteers should just come and help, so here I am), so please notify
> me for any mistake I do when using the review tools...
>
> The feature seems to work as expected, but I don't claim to be a markdown
> and rst expert.
> Some minor issues with the code itself :
> - some indentation issues (documentation and code itself with mix between
> space based and tab based indentation) and a few trailing spaces in code
>

corrected


> - typographic issues in the documentation :
>   - "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
> and rst formats" ==> duplicated and
>

corrected

>   - "Sets the output format to one of unaligned, aligned, wrapped, html,
> asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
> troff-ms." ==> extra comma at the end of the list
> - the comment " dont add line after last row, because line is added after
> every row" is misleading, it should warn that it's only for rst
> - there is a block of commented out code left
> - in the print_aligned_vertical function, there is a mix between
> "cont->opt->format == PRINT_RST" and "format == _rst" and I don't see
> any obvious reason for that
>
corrected

> - the documentation doesn't mention (but ok, it's kind of obvious) that
> the linestyle option will not work with rst and markdown
>
>
In this patch are corrected (i hope, i had correct changes in vimrc)
indentation issues. Plese, look at this if it is OK (i men indentats) and
some minor errors. And it should work on current master (probably).

Have nice day

Jan


> Thanks !
>
> The new status of this patch is: Waiting on Author
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 2a9c412020..ee0c8fbea6 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***
*** 2366,2372  lo_import 152801
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
!   latex-longtable, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
--- 2366,2373 
aligned, wrapped,
html, asciidoc,
latex (uses tabular),
! 		  latex-longtable, 
! 		  rst, markdown, or
troff-ms.
Unique abbreviations are allowed.  (That would mean one letter
is enough.)
***
*** 2394,2400  lo_import 152801
  

The html, asciidoc, latex,
!   latex-longtable, and troff-ms
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2395,2402 
  

The html, asciidoc, latex,
! 		  latex-longtable, troff-ms,
! 		  markdown and rst
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 4f4a0aa9bd..97f4f37923 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***
*** 2518,2523  _align2string(enum printFormat in)
--- 2518,2529 
  		case PRINT_TROFF_MS:
  			return "troff-ms";
  			break;
+ 		case PRINT_MARKDOWN:
+ 			return "markdown";
+ 			break;
+ 		case PRINT_RST:
+ 			return "rst";
+ 			break;
  	}
  	return "unknown";
  }
***
*** 2589,2597  do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
  			popt->topt.format = PRINT_LATEX_LONGTABLE;
  		else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
  			popt->topt.format = PRINT_TROFF_MS;
  		else
  		{
! 			psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
  			return false;
  		}
  	}
--- 2595,2607 
  			popt->topt.format = PRINT_LATEX_LONGTABLE;
  		else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
  			popt->topt.format = PRINT_TROFF_MS;
+ 		else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ 			popt->topt.format = PRINT_MARKDOWN;
+ 		else if (pg_strncasecmp("rst", value, vallen) == 0)
+ 			popt->topt.format = PRINT_RST;
  		else
  		{
! 			psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, 

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-23 Thread Jan Michálek
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet :

> The following review has been posted through the commitfest application:
> make installcheck-world:  tested, passed
> Implements feature:   tested, passed
> Spec compliant:   tested, passed
> Documentation:tested, passed
>
> Hi
>
> This is my first review (Magnus said in his presentation in PGDay Paris
> that volunteers should just come and help, so here I am), so please notify
> me for any mistake I do when using the review tools...
>
> The feature seems to work as expected, but I don't claim to be a markdown
> and rst expert.
> Some minor issues with the code itself :
> - some indentation issues (documentation and code itself with mix between
> space based and tab based indentation) and a few trailing spaces in code
> - typographic issues in the documentation :
>   - "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
> and rst formats" ==> duplicated and
>   - "Sets the output format to one of unaligned, aligned, wrapped, html,
> asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
> troff-ms." ==> extra comma at the end of the list
> - the comment " dont add line after last row, because line is added after
> every row" is misleading, it should warn that it's only for rst
> - there is a block of commented out code left
> - in the print_aligned_vertical function, there is a mix between
> "cont->opt->format == PRINT_RST" and "format == _rst" and I don't see
> any obvious reason for that
> - the documentation doesn't mention (but ok, it's kind of obvious) that
> the linestyle option will not work with rst and markdown
>
> Thanks !
>

Thanks
I will work on it this weekend. I need to adapt it to current master and i
will do some indentation issues with this.
I need to add \x to markdown format and some things about title from older
posts there.

Nice Day Je;



>
> The new status of this patch is: Waiting on Author
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-21 Thread Jan Michálek
2017-03-21 11:01 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:

>
>
> 2017-03-21 10:59 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>>
>>
>> 2017-03-21 9:59 GMT+01:00 Ideriha, Takeshi <ideriha.take...@jp.fujitsu.co
>> m>:
>>
>>> Hi,
>>>
>>> I like your suggestion and took a look at your patch though I’m not the
>>> expert about psql.
>>>
>>>
>>>
>>> I like the idea taking advantage of linestyle utilities
>>>
>>> to implement rst and markdown format efficiently instead of newly
>>> developing pset format things.
>>>
>>> But I'm thinking two comments below needs change to something about not
>>> focusing only linestyle.
>>>
>>> That's because they really take care of both '\pset linestyle and \pset
>>> format' and it may lead to misunderstanding to readers.
>>>
>>>
>>>
>>> ---
>>>
>>> /* Line style control structures */
>>>
>>> const printTextFormat pg_markdown =
>>>
>>>
>>>
>>> /* get selected or default line style */
>>>
>>> const printTextFormat *
>>>
>>> get_line_style(const printTableOpt *opt)
>>>
>>> ---
>>>
>>
>> It is in command.c?
>>
>> I have it done that \pset format changes linestyle
>>
>> psql (9.6.2, server 9.6.1)
>> Type "help" for help.
>>
>> jelen=# \pset linestyle ascii
>> Line style is ascii.
>> jelen=# \pset format rst
>> Output format is rst.
>> jelen=# \pset linestyle
>> Line style is rst.
>> jelen=#
>>
>> Peter wrote that this is not right, but i don`t know how it should like,
>> because most of this is done on linestyle, format is used only for switch
>> from console.
>>
>>
>>
>>>
>>>
>>> The rest things are about code style convention.
>>>
>>> - there are some indents with white spaces around
>>> skip_leading_spaces_print()
>>>
>>>   but Postgresql conventions says indents should be with 4 column tab.
>>>
>>>   https://www.postgresql.org/docs/devel/static/source-format.html
>>>
>>
>> Thanks, i often using 4 whitespaces (i have it in vim) but in other code
>> i found mostly used 8 whitespaces.
>> I will look on this. I use code from another functions (fputnbytes,
>> print_html_escaped) as template.
>>
>>
>>>
>>>
>>> - On the other hand, in docs there are some tab indent
>>>
>>>   but white space indenet is preferable. Looking around sgml files,
>>> white space is used.
>>>
>>>
>>>
>>> - some multi-line comment style also needs fix according to the above
>>> documentation (link)
>>>
>>
>> I will look on the comments, this is only work version, coding style
>> issues will be corrected (i have some comments only my orientation in code).
>>
>>
>>>
>>>
>>> - And I also found patch cannot be applied to current master.
>>>
>>
>> I have 9.6.2 source code. It is not correct? Where i find source code i
>> should use?
>>
>
> Please use git  master  https://wiki.postgresql.org/wiki/Working_with_Git
>
> Thanks, i will look on this on weekend.



> Regards
>
> Pavel
>
>>
>> Have nice day
>> Jan
>>
>>
>>>
>>>
>>> Regards,
>>>
>>> Ideriha, Takeshi
>>>
>>>
>>>
>>> *From:* pgsql-hackers-ow...@postgresql.org [mailto:
>>> pgsql-hackers-ow...@postgresql.org] *On Behalf Of *Jan Michalek
>>> *Sent:* Sunday, March 19, 2017 5:10 AM
>>> *To:* Peter Eisentraut <peter.eisentr...@2ndquadrant.com>
>>> *Cc:* Pavel Stehule <pavel.steh...@gmail.com>; PostgreSQL mailing lists
>>> <pgsql-hackers@postgresql.org>
>>> *Subject:* Re: [HACKERS] Other formats in pset like markdown, rst,
>>> mediawiki
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> 2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>
>>>
>>>
>>>
>>>
>>> 2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>
>>>
>>>
>>>
>>>
>>> 2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
>>> 

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-21 Thread Jan Michálek
2017-03-21 9:59 GMT+01:00 Ideriha, Takeshi <ideriha.take...@jp.fujitsu.com>:

> Hi,
>
> I like your suggestion and took a look at your patch though I’m not the
> expert about psql.
>
>
>
> I like the idea taking advantage of linestyle utilities
>
> to implement rst and markdown format efficiently instead of newly
> developing pset format things.
>
> But I'm thinking two comments below needs change to something about not
> focusing only linestyle.
>
> That's because they really take care of both '\pset linestyle and \pset
> format' and it may lead to misunderstanding to readers.
>
>
>
> ---
>
> /* Line style control structures */
>
> const printTextFormat pg_markdown =
>
>
>
> /* get selected or default line style */
>
> const printTextFormat *
>
> get_line_style(const printTableOpt *opt)
>
> ---
>

It is in command.c?

I have it done that \pset format changes linestyle

psql (9.6.2, server 9.6.1)
Type "help" for help.

jelen=# \pset linestyle ascii
Line style is ascii.
jelen=# \pset format rst
Output format is rst.
jelen=# \pset linestyle
Line style is rst.
jelen=#

Peter wrote that this is not right, but i don`t know how it should like,
because most of this is done on linestyle, format is used only for switch
from console.



>
>
> The rest things are about code style convention.
>
> - there are some indents with white spaces around
> skip_leading_spaces_print()
>
>   but Postgresql conventions says indents should be with 4 column tab.
>
>   https://www.postgresql.org/docs/devel/static/source-format.html
>

Thanks, i often using 4 whitespaces (i have it in vim) but in other code i
found mostly used 8 whitespaces.
I will look on this. I use code from another functions (fputnbytes,
print_html_escaped) as template.


>
>
> - On the other hand, in docs there are some tab indent
>
>   but white space indenet is preferable. Looking around sgml files, white
> space is used.
>
>
>
> - some multi-line comment style also needs fix according to the above
> documentation (link)
>

I will look on the comments, this is only work version, coding style issues
will be corrected (i have some comments only my orientation in code).


>
>
> - And I also found patch cannot be applied to current master.
>

I have 9.6.2 source code. It is not correct? Where i find source code i
should use?

Have nice day
Jan


>
>
> Regards,
>
> Ideriha, Takeshi
>
>
>
> *From:* pgsql-hackers-ow...@postgresql.org [mailto:pgsql-hackers-owner@
> postgresql.org] *On Behalf Of *Jan Michalek
> *Sent:* Sunday, March 19, 2017 5:10 AM
> *To:* Peter Eisentraut <peter.eisentr...@2ndquadrant.com>
> *Cc:* Pavel Stehule <pavel.steh...@gmail.com>; PostgreSQL mailing lists <
> pgsql-hackers@postgresql.org>
> *Subject:* Re: [HACKERS] Other formats in pset like markdown, rst,
> mediawiki
>
>
>
>
>
>
>
> 2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>
>
>
>
> 2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>
>
>
>
> 2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
> com>:
>
> This is looking pretty neat.  I played around with it a bit.  There are
> a couple of edge cases that you need to address, I think.
>
>
>
> Thanks, original code is very synoptical and and well prepared for adding
> new formats.
>
>
>
>
> - Does not support \x
>
>
>
> I know, i dnot`t know, if \x make sense in this case. I will look, how it
> is done in other formats like html. I think, that it should work in sense,
> that table generated to rst should give similar output after processing
> like output of html format.
>
>
>
> I prepared something like this (i have no prepared diff, i need do some
> another changes)
>
> There a few things I need to do. First problem is bold column names, i
> should do it in sme fashin as "RECORD", but i need to do some research
> about length of column.
>
> Bigger problem is with tab indent, rst processor doesn`t work with this in
> this case.
>
>
> In new diff is added \x for rst and skipping leading spaces in rst in
> both. make check passed
>
>
>
> Jan
>
>
>
>
>
> jelen=# execute q \g | xclip
> +-+-
> ---+
> | **RECORD 1**
> |
> +-+-
> ---+
> | column1 | Elephant, kangaroo,
> |
> | | squirrel, gorilla
> |
> +-+-
> ---+
> | colu

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-18 Thread Jan Michálek
2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

>
>
> 2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>>
>>
>> 2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
>> peter.eisentr...@2ndquadrant.com>:
>>
>>> This is looking pretty neat.  I played around with it a bit.  There are
>>> a couple of edge cases that you need to address, I think.
>>>
>>
>> Thanks, original code is very synoptical and and well prepared for adding
>> new formats.
>>
>>
>>>
>>> - Does not support \x
>>>
>>
>> I know, i dnot`t know, if \x make sense in this case. I will look, how it
>> is done in other formats like html. I think, that it should work in sense,
>> that table generated to rst should give similar output after processing
>> like output of html format.
>>
>>
> I prepared something like this (i have no prepared diff, i need do some
> another changes)
> There a few things I need to do. First problem is bold column names, i
> should do it in sme fashin as "RECORD", but i need to do some research
> about length of column.
> Bigger problem is with tab indent, rst processor doesn`t work with this in
> this case.
>

In new diff is added \x for rst and skipping leading spaces in rst in both.
make check passed

Jan


>
> jelen=# execute q \g | xclip
> +-+-
> ---+
> | **RECORD 1**
> |
> +-+-
> ---+
> | column1 | Elephant, kangaroo,
> |
> | | squirrel, gorilla
> |
> +-+-
> ---+
> | column2 | 121
> |
> +-+-
> ---+
> | column3 | 1.0035971223021583
> |
> +-+-
> ---+
> | column4 | 0.
> |
> +-+-
> ---+
> | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello
> Hello|
> +-+-
> ---+
> | **RECORD 2**
> |
> +-+-
> ---+
> | column1 | goat, rhinoceros,
>|
> | | monkey, ape
>  |
> +-+-
> ---+
> | column2 | 11121
> |
> +-+-
> ---+
> | column3 | 1.0007824726134585
> |
> +-+-
> ---+
> | column4 | 5.
> |
> +-+-
> ---+
> | column5 | xx xx xx xx xx xx xx xx xx
> xx  |
> +-+-
> ---+
> | **RECORD 3**
> |
> +-+-
> ---+
> | column1 | donkey, cow, horse, tit,
> |
> | | eagle, whale,
>   |
> | | aligator,
> |
> | |pelican,
>   |
> | | grasshoper
> |
> | | pig
> |
> | | bat
>  |
> +-+-
> ---+
> | column2 | 14351
> |
> +-+-
> ---+
> | column3 | 50.3877551020408163
> |
> +-+-
> ---+
> | column4 | 345.11
> |
> +-+-
> ---+
> | column5 | yy yy yy yy yy yy yy yy yy
> yy  |
> +-+-
> ---+
>
>
>
>
>
>>
>>> - When \pset format is rst, then \pset linestyle also shows up as
>>>   "rst".  That is wrong.  Same for markdown.
>>>
>>
>> I will look on this.
>>
>>
>>>
>>> - Broken output in tuples_only (\t) mode. (rst and markdown)
>>>
>>
>> Similar to \x, im not cer

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-12 Thread Jan Michálek
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

>
>
> 2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
> com>:
>
>> This is looking pretty neat.  I played around with it a bit.  There are
>> a couple of edge cases that you need to address, I think.
>>
>
> Thanks, original code is very synoptical and and well prepared for adding
> new formats.
>
>
>>
>> - Does not support \x
>>
>
> I know, i dnot`t know, if \x make sense in this case. I will look, how it
> is done in other formats like html. I think, that it should work in sense,
> that table generated to rst should give similar output after processing
> like output of html format.
>
>
I prepared something like this (i have no prepared diff, i need do some
another changes)
There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.
Bigger problem is with tab indent, rst processor doesn`t work with this in
this case.

jelen=# execute q \g | xclip
+-++
| **RECORD
1** |
+-++
| column1 | Elephant,
kangaroo,|
| | squirrel,
gorilla  |
+-++
| column2 |
121|
+-++
| column3 |
1.0035971223021583 |
+-++
| column4 |
0. |
+-++
| column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello
Hello|
+-++
| **RECORD
2** |
+-++
| column1 | goat,
rhinoceros,  |
| | monkey,
ape|
+-++
| column2 |
11121  |
+-++
| column3 |
1.0007824726134585 |
+-++
| column4 |
5. |
+-++
| column5 | xx xx xx xx xx xx xx xx xx
xx  |
+-++
| **RECORD
3** |
+-++
| column1 | donkey, cow, horse,
tit,   |
| | eagle,
whale,  |
| |
aligator,  |
| |
pelican,|
| |
grasshoper |
| |
pig|
| |
bat|
+-++
| column2 |
14351  |
+-++
| column3 |
50.3877551020408163|
+-++
| column4 |
345.11 |
+-++
| column5 | yy yy yy yy yy yy yy yy yy
yy  |
+-++





>
>

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-12 Thread Jan Michálek
I find, there is problem in tab indent in rst, it looks that lines should
be aligned to left in some cases.

2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

>
>
> 2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
> com>:
>
>> This is looking pretty neat.  I played around with it a bit.  There are
>> a couple of edge cases that you need to address, I think.
>>
>
> Thanks, original code is very synoptical and and well prepared for adding
> new formats.
>
>
>>
>> - Does not support \x
>>
>
> I know, i dnot`t know, if \x make sense in this case. I will look, how it
> is done in other formats like html. I think, that it should work in sense,
> that table generated to rst should give similar output after processing
> like output of html format.
>
>
>>
>> - When \pset format is rst, then \pset linestyle also shows up as
>>   "rst".  That is wrong.  Same for markdown.
>>
>
> I will look on this.
>
>
>>
>> - Broken output in tuples_only (\t) mode. (rst and markdown)
>>
>
> Similar to \x, im not certain, what it should return. I will look, what
> returns html format. Or i can use it in markdown for nice vs expanded
> format.
>
>
>>
>> - rst: Do something about \pset title; the way it currently shows up
>>   appears to be invalid; could use ".. table:: title" directive
>>
>
> OK, it shouldn`t be problem alter this.
>
>
>>
>> - markdown: Extra blank line between table and footer.
>>
>
> It is because markdown needs empty line after table, if is row count
> presented.
>
>
>>
>> - markdown: We should document or comment somewhere exactly which of the
>>   various markdown table formats this is supposed to produce.  (Pandoc
>>   pipe_tables?)
>>
>
> I use format that was similar to aligned format and ascii linestyle,
> because it allows me to use existing features. I should look over more
> table styles in markdown.
>
>
>>
>> - markdown: Table title needs to be after the table, like
>>
>> Table: title
>>
>> I will change this.
>
>
>> - markdown: Needs to escape | characters in cell contents.  (Not
>>   needed for rst.)  More escaping might be needed.
>>
>
> This can be problem because of aligning, i will look on this, this same
> problem as replace newline with  for markdown.
>
> Have Nice day
>
> Jan
>
>
>>
>> --
>> Peter Eisentraut  http://www.2ndQuadrant.com/
>> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>>
>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-10 Thread Jan Michálek
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
peter.eisentr...@2ndquadrant.com>:

> This is looking pretty neat.  I played around with it a bit.  There are
> a couple of edge cases that you need to address, I think.
>

Thanks, original code is very synoptical and and well prepared for adding
new formats.


>
> - Does not support \x
>

I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.


>
> - When \pset format is rst, then \pset linestyle also shows up as
>   "rst".  That is wrong.  Same for markdown.
>

I will look on this.


>
> - Broken output in tuples_only (\t) mode. (rst and markdown)
>

Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.


>
> - rst: Do something about \pset title; the way it currently shows up
>   appears to be invalid; could use ".. table:: title" directive
>

OK, it shouldn`t be problem alter this.


>
> - markdown: Extra blank line between table and footer.
>

It is because markdown needs empty line after table, if is row count
presented.


>
> - markdown: We should document or comment somewhere exactly which of the
>   various markdown table formats this is supposed to produce.  (Pandoc
>   pipe_tables?)
>

I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.


>
> - markdown: Table title needs to be after the table, like
>
> Table: title
>
> I will change this.


> - markdown: Needs to escape | characters in cell contents.  (Not
>   needed for rst.)  More escaping might be needed.
>

This can be problem because of aligning, i will look on this, this same
problem as replace newline with  for markdown.

Have Nice day

Jan


>
> --
> Peter Eisentraut  http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-06 Thread Jan Michálek
2017-03-06 19:45 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:

> On 3/5/17 05:40, Jan Michálek wrote:
> > jelen=# \pset linestyle rst
> > Line style is rst.
> > jelen=# \pset format wrapped
> > Output format is wrapped.
> > jelen=# SELECT repeat('Goodnight Irene ', 30);
> > +---
> --+
> > |
> > repeat|
> > +===
> ==+
> > | Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
> > Goodnight I.|
> > |.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
> > Goodni.|
> > |.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
> > Irene G.|
>
> I doubt that this kind of line breaking style is actually proper rst.
>

If you mean wrapped lines, it is wrapped by email client (in sent messages
it looks as a table).
But really, this rst (original version from sent messages) doesn`t work (I
actually test it) and don`t know why, but problem is probably related with
linebreaks.
In last wersion of diff is pset changed from linestyle to format and using
"wrapped" format is not possible.

Regards

Jan


> --
> Peter Eisentraut  http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-06 Thread Jan Michálek
2017-03-06 16:25 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:

>
>
> 2017-03-06 16:17 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>>
>>
>> 2017-03-06 15:19 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>
>>>
>>>
>>> 2017-03-06 0:26 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>
>>>>
>>>>
>>>> 2017-03-05 14:02 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>>
>>>>>
>>>>>
>>>>> 2017-03-05 13:39 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>>>>
>>>>>>
>>>>>>
>>>>>> 2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>>>>>
>>>>>>>> It is question if it is really new format, because formating is the
>>>>>>>> same as aligned/wrapped format, changed is only style of lines.
>>>>>>>>
>>>>>>>
>>>>>>> Please, don't do top posting https://en.wikipedia.org/wiki/
>>>>>>> Posting_style#Top-posting
>>>>>>>
>>>>>>>
>>>>>>>> 2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>>>>>>>
>>>>>>>>>> I know, but, both new linestyles are created literally by cloning
>>>>>>>>>> ascii linestyle and few lines in print_aligned_text. Both works with
>>>>>>>>>> "aligned" and "wrapped" format. In rst is wrapped format useful, in 
>>>>>>>>>> my
>>>>>>>>>> opinion, in markdown i can`t find how I can get newline in record 
>>>>>>>>>> (maybe it
>>>>>>>>>> is not posiible in main markdown types). So it is why i add markdown 
>>>>>>>>>> and
>>>>>>>>>> rst as new linestyles. But it is not problem to change it in command 
>>>>>>>>>> to use
>>>>>>>>>> "\pset format", but i mean, that this is cleaner.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Using a special linestyle for new format is possible probably. But
>>>>>>>>> new format should be switched with \pset format command.
>>>>>>>>>
>>>>>>>>
>>>> changed
>>>>
>>>
>>> quick test shows it is working.
>>>
>>> Just idea - can you specify aligning? right aligning for numbers, left
>>> for others?
>>>
>>
>> I used "aligned" format as it is and I don`t know, if I`m able to do this
>> with current solution based only on change linestyle internally.
>>
>
> you can try to test result in some markdown processors? I will not be
> surprised if these processor ignore aligning in input data.
>

I tested markdown only in retext and retext aligns columns set by -:|
well.

>
> Refards
>
> Pavel
>
>
>
>>
>>> Regards
>>>
>>> Pavel
>>>
>>>
>>
>>
>> --
>> Jelen
>> Starší čeledín datovýho chlíva
>>
>
>


-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-06 Thread Jan Michálek
2017-03-05 14:02 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

>
>
> 2017-03-05 13:39 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>
>>
>>
>> 2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>
>>>
>>>
>>> 2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>
>>>> It is question if it is really new format, because formating is the
>>>> same as aligned/wrapped format, changed is only style of lines.
>>>>
>>>
>>> Please, don't do top posting https://en.wikipedia.org/wiki/
>>> Posting_style#Top-posting
>>>
>>>
>>>> 2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>>>
>>>>>
>>>>>
>>>>> 2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>>>
>>>>>> I know, but, both new linestyles are created literally by cloning
>>>>>> ascii linestyle and few lines in print_aligned_text. Both works with
>>>>>> "aligned" and "wrapped" format. In rst is wrapped format useful, in my
>>>>>> opinion, in markdown i can`t find how I can get newline in record (maybe 
>>>>>> it
>>>>>> is not posiible in main markdown types). So it is why i add markdown and
>>>>>> rst as new linestyles. But it is not problem to change it in command to 
>>>>>> use
>>>>>> "\pset format", but i mean, that this is cleaner.
>>>>>>
>>>>>
>>>>> Using a special linestyle for new format is possible probably. But new
>>>>> format should be switched with \pset format command.
>>>>>
>>>>
changed

>
>>>>> Not sure if wrapped or aligned behave is correct for markdown - it is
>>>>> task for markdown processing, not for psql.
>>>>>
>>>>
>>>
>>>
>>> In this case I am inclined to prefer setting via format setting - you
>>> can set a linestyle and border in one step, and then is easy to return back
>>> to previous format. I don't see a big benefit in enhancing set of ascii
>>> linestyles. The collecting new features in formatting is more intuitive
>>> (for me).
>>>
>>
>>  This can be discussed what we prefer, and what we would to implement?
>>
>>
>>
>> 1. Nice formatted markdown tables
>>
>>
>> | Tables| Are   | Cool  |
>> | - |:-:| -:|
>> | col 3 is  | right-aligned | $1600 |
>> | col 2 is  | centered  |   $12 |
>> | zebra stripes | are neat  |$1 |
>>
>> or 2. enough formatting
>>
>>
>> Markdown | Less | Pretty
>> --- | --- | ---
>> *Still* | `renders` | **nicely**
>> 1 | 2 | 3
>>
>> I personally prefer nice formated table, because more comfortable reading
> source of document and easier editing with blocks (deleting whole columns
> etc.).
> I will change \pset to format.
> I find, when adding <\br> for newline works in retext. I will try to add
> it to patch.
>
> | Tables | Are | Cool |
>
> | - |:-:| -:|
>
> | col 3 is | right-aligned | $1600 |
>
> | col 2 is | centered | $12 |
>
> | zebra stripes | are neat | $1 |
>
>
> Jan
>
>
>
>> Pavel
>>
>>
>>
>>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml2017-02-06 22:45:25.0 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml2017-03-06 01:35:46.0 +0100
@@ -2326,7 +2326,8 @@
   aligned, wrapped,
   html, asciidoc,
   latex (uses tabular),
-  latex-longtable, or
+  latex-longtable, 
+ rst, markdown, or
   troff-ms.
   Unique abbreviations are allowed.  (That would mean one letter
   is enough.)
@@ -2354,7 +2355,8 @@
 
   
   The html, asciidoc, latex,
-  latex-longtable, and troff-ms
+  latex-longtable, troff-ms,
+ and markdown and rst
   formats put out tables that are intended to
   be included in documents using the respective mark-up
   language. They are not complete documents! This might not be
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c2017-02-06 22:45:25.0 +010

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-05 Thread Jan Michálek
2017-03-05 13:39 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:

>
>
> 2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>
>>
>>
>> 2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>
>>> It is question if it is really new format, because formating is the same
>>> as aligned/wrapped format, changed is only style of lines.
>>>
>>
>> Please, don't do top posting https://en.wikipedia.org/wiki/
>> Posting_style#Top-posting
>>
>>
>>> 2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:
>>>
>>>>
>>>>
>>>> 2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>>>
>>>>> I know, but, both new linestyles are created literally by cloning
>>>>> ascii linestyle and few lines in print_aligned_text. Both works with
>>>>> "aligned" and "wrapped" format. In rst is wrapped format useful, in my
>>>>> opinion, in markdown i can`t find how I can get newline in record (maybe 
>>>>> it
>>>>> is not posiible in main markdown types). So it is why i add markdown and
>>>>> rst as new linestyles. But it is not problem to change it in command to 
>>>>> use
>>>>> "\pset format", but i mean, that this is cleaner.
>>>>>
>>>>
>>>> Using a special linestyle for new format is possible probably. But new
>>>> format should be switched with \pset format command.
>>>>
>>>> Not sure if wrapped or aligned behave is correct for markdown - it is
>>>> task for markdown processing, not for psql.
>>>>
>>>
>>
>>
>> In this case I am inclined to prefer setting via format setting - you can
>> set a linestyle and border in one step, and then is easy to return back to
>> previous format. I don't see a big benefit in enhancing set of ascii
>> linestyles. The collecting new features in formatting is more intuitive
>> (for me).
>>
>
>  This can be discussed what we prefer, and what we would to implement?
>
>
>
> 1. Nice formatted markdown tables
>
>
> | Tables| Are   | Cool  |
> | - |:-:| -:|
> | col 3 is  | right-aligned | $1600 |
> | col 2 is  | centered  |   $12 |
> | zebra stripes | are neat  |$1 |
>
> or 2. enough formatting
>
>
> Markdown | Less | Pretty
> --- | --- | ---
> *Still* | `renders` | **nicely**
> 1 | 2 | 3
>
> I personally prefer nice formated table, because more comfortable reading
source of document and easier editing with blocks (deleting whole columns
etc.).
I will change \pset to format.
I find, when adding <\br> for newline works in retext. I will try to add it
to patch.

| Tables | Are | Cool |

| - |:-:| -:|

| col 3 is | right-aligned | $1600 |

| col 2 is | centered | $12 |

| zebra stripes | are neat | $1 |


Jan



> Pavel
>
>
>
>


-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-05 Thread Jan Michálek
It is question if it is really new format, because formating is the same as
aligned/wrapped format, changed is only style of lines.

2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.steh...@gmail.com>:

>
>
> 2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>> I know, but, both new linestyles are created literally by cloning ascii
>> linestyle and few lines in print_aligned_text. Both works with "aligned"
>> and "wrapped" format. In rst is wrapped format useful, in my opinion, in
>> markdown i can`t find how I can get newline in record (maybe it is not
>> posiible in main markdown types). So it is why i add markdown and rst as
>> new linestyles. But it is not problem to change it in command to use "\pset
>> format", but i mean, that this is cleaner.
>>
>
> Using a special linestyle for new format is possible probably. But new
> format should be switched with \pset format command.
>
> Not sure if wrapped or aligned behave is correct for markdown - it is task
> for markdown processing, not for psql.
>
> Regards
>
> Pavel
>
>
>
>>
>> Je;
>>
>>
>> jelen=# \pset linestyle rst
>> Line style is rst.
>> jelen=# \pset format wrapped
>> Output format is wrapped.
>> jelen=# SELECT repeat('Goodnight Irene ', 30);
>> +---
>> --+
>> |   repeat
>> |
>> +===
>> ==+
>> | Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
>> Goodnight I.|
>> |.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
>> Goodni.|
>> |.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
>> Irene G.|
>> |.oodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
>> Goodnight Ir.|
>> |.ene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
>> Goodnig.|
>> |.ht Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
>> Irene Go.|
>> |.odnight Irene Goodnight Irene
>> |
>> +---
>> --+
>>
>> (1 row)
>>
>> jelen=#
>>
>>
>> 2017-03-01 15:00 GMT+01:00 Peter Eisentraut <
>> peter.eisentr...@2ndquadrant.com>:
>>
>>> If you want to implement a new table format, you should be looking at
>>> \pset format, not \pset linestyle.  \pset format sets different table
>>> formats, such as html, latex, and asciidoc.  \pset linestyle just
>>> chooses between different styles for the plain-text table format.
>>>
>>> On 3/1/17 06:31, Jan Michálek wrote:
>>> > Regression test corrected.
>>> >
>>> > 2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com
>>> > <mailto:godzilalal...@gmail.com>>:
>>> >
>>> > Sorry, I have some errors in my diff, i had copy something from bad
>>> > folder. I will fix it.
>>> >
>>> > 2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalal...@gmail.com
>>> > <mailto:godzilalal...@gmail.com>>:
>>> >
>>> > There it is, what i have.
>>> > I need i small help with psql.out, because \pset format
>>> wrapped.
>>> > I don`t know, how to have it in fixed width.
>>> >
>>> > 2017-02-28 14:23 GMT+01:00 Jan Michálek <
>>> godzilalal...@gmail.com
>>> > <mailto:godzilalal...@gmail.com>>:
>>> >
>>> > Current state is something like this (diff is attached).
>>> > I currently haven`t regression test, tab completion etc., I
>>> > will add this thing following structure of asciidoc commit.
>>> >
>>> > Output is tested using retext, rst is OK, md have problem
>>> > with cells with newline (i must find out, how it is
>>> possible
>>> > create table with this in markdown).
>>> >
>>> > [jelen@laptak patch_postgre_rst]$
>>> > [jelen@laptak psql]$ ./psql
>>> > psql (9.6.2, server 9.6.1)
>>> > Type "help" for help.
>>> >
>>> > jelen=# \pset linestyle markdown
>>> > Line style is markdown.
>>> > jelen=# values(E'nasral Fran

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-05 Thread Jan Michálek
I know, but, both new linestyles are created literally by cloning ascii
linestyle and few lines in print_aligned_text. Both works with "aligned"
and "wrapped" format. In rst is wrapped format useful, in my opinion, in
markdown i can`t find how I can get newline in record (maybe it is not
posiible in main markdown types). So it is why i add markdown and rst as
new linestyles. But it is not problem to change it in command to use "\pset
format", but i mean, that this is cleaner.

Je;


jelen=# \pset linestyle rst
Line style is rst.
jelen=# \pset format wrapped
Output format is wrapped.
jelen=# SELECT repeat('Goodnight Irene ', 30);
+-+
|
repeat|
+=+
| Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
I.|
|.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Goodni.|
|.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
G.|
|.oodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
Ir.|
|.ene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Goodnig.|
|.ht Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Go.|
|.odnight Irene Goodnight
Irene   |
+-+

(1 row)

jelen=#


2017-03-01 15:00 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:

> If you want to implement a new table format, you should be looking at
> \pset format, not \pset linestyle.  \pset format sets different table
> formats, such as html, latex, and asciidoc.  \pset linestyle just
> chooses between different styles for the plain-text table format.
>
> On 3/1/17 06:31, Jan Michálek wrote:
> > Regression test corrected.
> >
> > 2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com
> > <mailto:godzilalal...@gmail.com>>:
> >
> > Sorry, I have some errors in my diff, i had copy something from bad
> > folder. I will fix it.
> >
> > 2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalal...@gmail.com
> > <mailto:godzilalal...@gmail.com>>:
> >
> > There it is, what i have.
> > I need i small help with psql.out, because \pset format wrapped.
> > I don`t know, how to have it in fixed width.
> >
> > 2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalal...@gmail.com
> > <mailto:godzilalal...@gmail.com>>:
> >
> > Current state is something like this (diff is attached).
> > I currently haven`t regression test, tab completion etc., I
> > will add this thing following structure of asciidoc commit.
> >
> > Output is tested using retext, rst is OK, md have problem
> > with cells with newline (i must find out, how it is possible
> > create table with this in markdown).
> >
> > [jelen@laptak patch_postgre_rst]$
> > [jelen@laptak psql]$ ./psql
> > psql (9.6.2, server 9.6.1)
> > Type "help" for help.
> >
> > jelen=# \pset linestyle markdown
> > Line style is markdown.
> > jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
> > kobyly'), (,E'a\tb') \g | xclip
> > jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
> > kobyly'), (,E'a\tb') \g
> >
> > |column1| column2  |
> > |---|--|
> > | nasral Franta | Žluťoučký kobyly |
> > | na trabanta   |  |
> > | ' | a   b|
> >
> >
> > (2 rows)
> >
> > jelen=# \pset linestyle rst
> > Line style is rst.
> > jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
> > kobyly'), (,E'a\tb') \g
> > +---+--+
> > |column1| column2  |
> > +===+==+
> > | nasral Franta+| Žluťoučký kobyly |
> > | na trabanta   |      |
> > +---+--+
> > | ' | a   b|
> > +---+--+
> >
> > (2 rows)
> >
> >   

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-01 Thread Jan Michálek
Regression test corrected.

2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

> Sorry, I have some errors in my diff, i had copy something from bad
> folder. I will fix it.
>
> 2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>> There it is, what i have.
>> I need i small help with psql.out, because \pset format wrapped. I don`t
>> know, how to have it in fixed width.
>>
>> 2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>>
>>> Current state is something like this (diff is attached).
>>> I currently haven`t regression test, tab completion etc., I will add
>>> this thing following structure of asciidoc commit.
>>>
>>> Output is tested using retext, rst is OK, md have problem with cells
>>> with newline (i must find out, how it is possible create table with this in
>>> markdown).
>>>
>>> [jelen@laptak patch_postgre_rst]$
>>> [jelen@laptak psql]$ ./psql
>>> psql (9.6.2, server 9.6.1)
>>> Type "help" for help.
>>>
>>> jelen=# \pset linestyle markdown
>>> Line style is markdown.
>>> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
>>> (,E'a\tb') \g | xclip
>>> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
>>> (,E'a\tb') \g
>>>
>>> |column1| column2  |
>>> |---|--|
>>> | nasral Franta | Žluťoučký kobyly |
>>> | na trabanta   |  |
>>> | ' | a   b|
>>>
>>>
>>> (2 rows)
>>>
>>> jelen=# \pset linestyle rst
>>> Line style is rst.
>>> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
>>> (,E'a\tb') \g
>>> +---+--+
>>> |column1| column2  |
>>> +===+==+
>>> | nasral Franta+| Žluťoučký kobyly |
>>> | na trabanta   |  |
>>> +---+--+
>>> | ' | a   b|
>>> +---+--+
>>>
>>> (2 rows)
>>>
>>> jelen=#
>>>
>>> 2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paqu...@gmail.com>:
>>>
>>>> On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalal...@gmail.com>
>>>> wrote:
>>>> > I can try it, doesn`t look dificult, but I`m worry, that I`m not able
>>>> to
>>>> > write clean, pretty code.
>>>>
>>>> If you want to have something available in Postgres 10, you had better
>>>> be quick. The last commit fest of the development cycle of Postgres 10
>>>> begins on the 1st of March, you need to to register your patch here:
>>>> https://commitfest.postgresql.org/13/
>>>> Here are also some rough guidelines about submitting a patch:
>>>> https://wiki.postgresql.org/wiki/Submitting_a_Patch
>>>> --
>>>> Michael
>>>>
>>>
>>>
>>>
>>> --
>>> Jelen
>>> Starší čeledín datovýho chlíva
>>>
>>
>>
>>
>> --
>> Jelen
>> Starší čeledín datovýho chlíva
>>
>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml2017-02-06 22:45:25.0 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml2017-03-01 00:37:19.0 +0100
@@ -2373,6 +2373,7 @@
   
   Sets the border line drawing style to one
   of ascii, old-ascii,
+ , rst, markdown
   or unicode.
   Unique abbreviations are allowed.  (That would mean one
   letter is enough.)
@@ -2408,6 +2409,12 @@
   again in the left-hand margin of the following line.
   
 
+ rst and markdown format
+ tables for use restructured text on markdown documents. Both of them 
+ works well only with format aligned and border
+ 2.
+ 
+
   
   When the border setting is greater than zero,
   the linestyle option also determines the
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c2017-02-06 22:45:25.0 +0100
+++ b/src/bin/psql/command.c2017-03-01 01:12:17.0 +0100
@@ -2584,9 +2584,17 @@
popt->topt.line_style = _asciiformat_old;
else if (pg_strncasecmp(&q

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-03-01 Thread Jan Michálek
Sorry, I have some errors in my diff, i had copy something from bad folder.
I will fix it.

2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

> There it is, what i have.
> I need i small help with psql.out, because \pset format wrapped. I don`t
> know, how to have it in fixed width.
>
> 2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:
>
>> Current state is something like this (diff is attached).
>> I currently haven`t regression test, tab completion etc., I will add this
>> thing following structure of asciidoc commit.
>>
>> Output is tested using retext, rst is OK, md have problem with cells with
>> newline (i must find out, how it is possible create table with this in
>> markdown).
>>
>> [jelen@laptak patch_postgre_rst]$
>> [jelen@laptak psql]$ ./psql
>> psql (9.6.2, server 9.6.1)
>> Type "help" for help.
>>
>> jelen=# \pset linestyle markdown
>> Line style is markdown.
>> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
>> (,E'a\tb') \g | xclip
>> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
>> (,E'a\tb') \g
>>
>> |column1| column2  |
>> |---|--|
>> | nasral Franta | Žluťoučký kobyly |
>> | na trabanta   |  |
>> | ' | a   b|
>>
>>
>> (2 rows)
>>
>> jelen=# \pset linestyle rst
>> Line style is rst.
>> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
>> (,E'a\tb') \g
>> +---+--+
>> |column1| column2  |
>> +===+==+
>> | nasral Franta+| Žluťoučký kobyly |
>> | na trabanta   |  |
>> +---+--+
>> | ' | a   b|
>> +---+--+
>>
>> (2 rows)
>>
>> jelen=#
>>
>> 2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paqu...@gmail.com>:
>>
>>> On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalal...@gmail.com>
>>> wrote:
>>> > I can try it, doesn`t look dificult, but I`m worry, that I`m not able
>>> to
>>> > write clean, pretty code.
>>>
>>> If you want to have something available in Postgres 10, you had better
>>> be quick. The last commit fest of the development cycle of Postgres 10
>>> begins on the 1st of March, you need to to register your patch here:
>>> https://commitfest.postgresql.org/13/
>>> Here are also some rough guidelines about submitting a patch:
>>> https://wiki.postgresql.org/wiki/Submitting_a_Patch
>>> --
>>> Michael
>>>
>>
>>
>>
>> --
>> Jelen
>> Starší čeledín datovýho chlíva
>>
>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva


Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-02-28 Thread Jan Michálek
There it is, what i have.
I need i small help with psql.out, because \pset format wrapped. I don`t
know, how to have it in fixed width.

2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalal...@gmail.com>:

> Current state is something like this (diff is attached).
> I currently haven`t regression test, tab completion etc., I will add this
> thing following structure of asciidoc commit.
>
> Output is tested using retext, rst is OK, md have problem with cells with
> newline (i must find out, how it is possible create table with this in
> markdown).
>
> [jelen@laptak patch_postgre_rst]$
> [jelen@laptak psql]$ ./psql
> psql (9.6.2, server 9.6.1)
> Type "help" for help.
>
> jelen=# \pset linestyle markdown
> Line style is markdown.
> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
> (,E'a\tb') \g | xclip
> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
> (,E'a\tb') \g
>
> |column1| column2  |
> |---|--|
> | nasral Franta | Žluťoučký kobyly |
> | na trabanta   |  |
> | ' | a   b|
>
>
> (2 rows)
>
> jelen=# \pset linestyle rst
> Line style is rst.
> jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
> (,E'a\tb') \g
> +---+--+
> |column1| column2  |
> +===+==+
> | nasral Franta+| Žluťoučký kobyly |
> | na trabanta   |  |
> +---+--+
> | ' | a   b|
> +---+--+
>
> (2 rows)
>
> jelen=#
>
> 2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paqu...@gmail.com>:
>
>> On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalal...@gmail.com>
>> wrote:
>> > I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
>> > write clean, pretty code.
>>
>> If you want to have something available in Postgres 10, you had better
>> be quick. The last commit fest of the development cycle of Postgres 10
>> begins on the 1st of March, you need to to register your patch here:
>> https://commitfest.postgresql.org/13/
>> Here are also some rough guidelines about submitting a patch:
>> https://wiki.postgresql.org/wiki/Submitting_a_Patch
>> --
>> Michael
>>
>
>
>
> --
> Jelen
> Starší čeledín datovýho chlíva
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml2017-02-06 22:45:25.0 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml2017-03-01 00:37:19.0 +0100
@@ -2373,6 +2373,7 @@
   
   Sets the border line drawing style to one
   of ascii, old-ascii,
+ , rst, markdown
   or unicode.
   Unique abbreviations are allowed.  (That would mean one
   letter is enough.)
@@ -2408,6 +2409,12 @@
   again in the left-hand margin of the following line.
   
 
+ rst and markdown format
+ tables for use restructured text on markdown documents. Both of them 
+ works well only with format aligned and border
+ 2.
+ 
+
   
   When the border setting is greater than zero,
   the linestyle option also determines the
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c2017-02-06 22:45:25.0 +0100
+++ b/src/bin/psql/command.c2017-03-01 01:12:17.0 +0100
@@ -2584,9 +2584,17 @@
popt->topt.line_style = _asciiformat_old;
else if (pg_strncasecmp("unicode", value, vallen) == 0)
popt->topt.line_style = _utf8format;
+   /* format markdown
+   */
+   else if (pg_strncasecmp("markdown", value, vallen) == 0)
+   popt->topt.line_style = _markdown;
+   /* format rst
+   */
+   else if (pg_strncasecmp("rst", value, vallen) == 0)
+   popt->topt.line_style = _rst;
else
{
-   psql_error("\\pset: allowed line styles are ascii, 
old-ascii, unicode\n");
+   psql_error("\\pset: allowed line styles are ascii, 
old-ascii, unicode, markdown, rst\n");
return false;
}
 
diff -ru a/src/bin/psql/help.c b/src/bin/psql/help.c
--- a/src/bin/psql/help.c   2017-02-06 22:45:25.0 +0100
+++ b/src/bin/psql/help.c   2017-03-01 00:59:07.0 +0100
@@ -374,7 +374,7 @@
fprintf(output, _("  fie

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-02-28 Thread Jan Michálek
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I will add this
thing following structure of asciidoc commit.

Output is tested using retext, rst is OK, md have problem with cells with
newline (i must find out, how it is possible create table with this in
markdown).

[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.

jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
(,E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
(,E'a\tb') \g

|column1| column2  |
|---|--|
| nasral Franta | Žluťoučký kobyly |
| na trabanta   |  |
| ' | a   b|


(2 rows)

jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
(,E'a\tb') \g
+---+--+
|column1| column2  |
+===+==+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta   |  |
+---+--+
| ' | a   b|
+---+--+

(2 rows)

jelen=#

2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paqu...@gmail.com>:

> On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalal...@gmail.com>
> wrote:
> > I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
> > write clean, pretty code.
>
> If you want to have something available in Postgres 10, you had better
> be quick. The last commit fest of the development cycle of Postgres 10
> begins on the 1st of March, you need to to register your patch here:
> https://commitfest.postgresql.org/13/
> Here are also some rough guidelines about submitting a patch:
> https://wiki.postgresql.org/wiki/Submitting_a_Patch
> --
> Michael
>



-- 
Jelen
Starší čeledín datovýho chlíva
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c2017-02-06 22:45:25.0 +0100
+++ b/src/bin/psql/command.c2017-02-28 01:07:26.0 +0100
@@ -2584,9 +2584,17 @@
popt->topt.line_style = _asciiformat_old;
else if (pg_strncasecmp("unicode", value, vallen) == 0)
popt->topt.line_style = _utf8format;
+   /* format markdown
+   */
+   else if (pg_strncasecmp("markdown", value, vallen) == 0)
+   popt->topt.line_style = _markdown;
+   /* format rst
+   */
+   else if (pg_strncasecmp("rst", value, vallen) == 0)
+   popt->topt.line_style = _rst;
else
{
-   psql_error("\\pset: allowed line styles are ascii, 
old-ascii, unicode\n");
+   psql_error("\\pset: allowed line styles are ascii, 
old-ascii, unicode, markdown\n");
return false;
}
 
diff -ru a/src/fe_utils/print.c b/src/fe_utils/print.c
--- a/src/fe_utils/print.c  2017-02-06 22:45:25.0 +0100
+++ b/src/fe_utils/print.c  2017-02-28 13:34:11.0 +0100
@@ -57,6 +57,48 @@
 static printTableFooter default_footer_cell = {default_footer, NULL};
 
 /* Line style control structures */
+const printTextFormat pg_markdown =
+{
+   "markdown",
+   {
+   {"", "", "", ""},
+   {"-", "|", "|", "|"},
+   {"", "", "", ""},
+   {"", "|", "|", "|"}
+   },
+   "|",
+   "|",
+   "|",
+   " ",
+   "+",
+   " ",
+   " ",
+   ".",
+   ".",
+   true
+};
+
+const printTextFormat pg_rst =
+{
+   "rst",
+   {
+   {"-", "+", "+", "+"},
+   {"=", "+", "+", "+"},
+   {"-", "+", "+", "+"},
+   {"", "|", "|", "|"}
+   },
+   "|",
+   "|",
+   "|",
+   " ",
+   "+",
+   " ",
+   "+",
+   ".",
+   ".",
+   true
+};
+
 const printTextFormat pg_asciiformat =
 {
"ascii",
@@ -623,6 +665,12 @@
if (opt_border > 2)
opt_border = 2;
 
+   if (format ==

Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-02-23 Thread Jan Michálek
I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.

2017-02-23 18:03 GMT+01:00 Alvaro Herrera :

> Leknín Řepánek wrote:
> > I was mainly using tables in rst, i think, that this format is very
> > similar to "grid tables" in markdown. And it is really similar to
> default borders used
> > in psql with border 2.
>
> Great.  So are you writing the code now?  :-)
>
> --
> Álvaro Herrerahttps://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>



-- 
Jelen
Starší čeledín datovýho chlíva


[HACKERS] Other formats in pset like markdown, rst, mediawiki

2017-02-23 Thread Jan Michálek
Have a nice day
I`m using \pset format html for generating tables for some documentation,
training, reports, blogs... Mainly sample of data for SQL queries, or
explaining structure etc.
But in some software like sphinx, wiki on redmine, or markdown on github
issues I`m not able to insert table in html into text. Using some
converters or sed script is little bit tricky if I need to create reports
from bash scripts, for example by jenkins.
Is there posibility, that support for some others formats will be added in
the future? Or id posible to create some of this formats by manipulating
with pset? Or I need use xml for export and use some xslt templates, or
lxml etc. to create format that I will be able to copy on wiki page or in
github issue.

Thanks Je;

-- 
Jelen
Starší čeledín datovýho chlíva