Re: Markdown format output for psql, design notes

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Lætitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Markdown format output for psql, design notes
Date: 2018-11-28 10:04:29
Message-ID: CAFj8pRCySvkJPaAoMjsc35GhNv_BXoCDrobnO6GSNKQQQP6K+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

st 28. 11. 2018 v 9:59 odesílatel Lætitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
napsal:

> Hi all,
>
> # What I'd like to do
> I've been working on the idea of a markdown format for psql as I had said
> in that thread :
> https://www.postgresql.org/message-id/flat/CAB_COdiiwTmBcrmjXWCKiqkcPgf_bLodrUyb4GYE6pfKeoK2eg%40mail.gmail.com
>
> An attempt was made a year ago (see here :
> https://www.postgresql.org/message-id/flat/CAAYBy8bs%3D8vz6Ps_nLW24NJhqcxz4bsWBLawAiwWSPSLdWSmvA%40mail.gmail.com#eb7b6eb6daa60aac1f5fa001f934f89a),
> but didn't end up with something commitable.
>
> What's more, I quite disagree with `\pset linestyle markdown` option to
> have a markdown output in psql, I prefer `\pset format markdown`.
>

sure +1

> # Some official doc about markdown So here are my thoughts (before
> writing any code) :
>
> 1. "Official" markdown seems to be the daring fireball project (see
> Aaron Schwartz's note here http://www.aaronsw.com/weblog/001189)
> 2. Official markdown doesn't support table formatting. Authors said we
> could just use HTML inside markdown to do so (it's quite not readable for a
> human, that's why I don't like this option) -> see here:
> https://daringfireball.net/projects/markdown/syntax#html
> 3. Table markdown is introduced in "Markdown Extra" that was first
> implemented in PHP (see here
> https://michelf.ca/projects/php-markdown/extra/#table)
> 4. I want to make the patch as simple as possible, so I won't
> implement cell alignment
>
> # The result I want
> From points 3 and 4, here is what I'd like to see :
>
> | Header 1 | Header 2 | Header 3 |
> |----------|----------|----------|
> | content | content | content |
> | content | content | content |
> (2 rows)
>

+1

> ***'|' at beginning and end of line are optional in markdown extra, but it
> seems as a consensus to always add them. You may challenge this choice, I'm
> open to discussion.***
>
> From the fireball project (
> https://daringfireball.net/projects/markdown/syntax#backslash) and
> markdown extra (https://michelf.ca/projects/php-markdown/extra/#backslash),
> it seems we need to backslash escape all of those characters:
>
> ~~~
> \ backslash
> ` backtick
> * asterisk
> _ underscore
> {} curly braces
> [] square brackets
> () parentheses
> # hash mark
> + plus sign
> - minus sign (hyphen)
> . dot
> ! exclamation mark
> : colon
> | pipe
> ~~~
>
> # psql syntax to get that
> It feels to me that we should use the `\pset format` (or `-P` or `--pset=`
> in batch mode) syntax to tell psql we want markdown. So any of that one
> should provide a markdown output :
>
> - `psql -P format=markdown`
> - `psql --pset=format=markdown`
> - `\pset format markdown` (in psql prompt command)
>
> # Code to change
> If I want to code that patch, here are the files I think I'll need to
> change :
>
> - Documentation
> - doc/src/sgml/rel/psql-ref.sgml
> - src/bin/psql/help.c
> - Tests
> - src/test/regress/expected/psql.out
> - src/test/regress/sql/psql.sql
> - Code
> - src/bin/psql/command.c
> - src/bin/psql/tab-complete.c
>
> ***You're welcome to add any other file that I missed in that list!***
>
> # What I'd like you to do
> First, thanks to have read that whole mail and sorry I didn't mean to make
> it so long...
> Then I'd like to know ***what you think about what I'm about to do***
> before heading in a wrong direction.
>
> Have a nice day,
>
> Lætitia
> --
> *Think! Do you really need to print this email ? *
> *There is no Planet B.*
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergei Kornilov 2018-11-28 11:15:18 Re: New function pg_stat_statements_reset_query() to reset statistics of a specific query
Previous Message Konstantin Knizhnik 2018-11-28 10:01:03 VOPS-2.0