Markdown format output for psql, design notes - Mailing list pgsql-hackers
From | Lætitia Avrot |
---|---|
Subject | Markdown format output for psql, design notes |
Date | |
Msg-id | CAB_COdgqkhVejNhjfGYuFmFZG8r33BgE4d1Ag211JoTCFRv0bA@mail.gmail.com Whole thread Raw |
Responses |
Re: Markdown format output for psql, design notes
Re: Markdown format output for psql, design notes Re: Markdown format output for psql, design notes |
List | pgsql-hackers |
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
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`.
What's more, I quite disagree with `\pset linestyle markdown` option to have a markdown output in psql, I prefer `\pset format markdown`.
# Some official doc about markdown So here are my thoughts (before writing any code) :
- "Official" markdown seems to be the daring fireball project (see Aaron Schwartz's note here http://www.aaronsw.com/weblog/001189)
- 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
- Table markdown is introduced in "Markdown Extra" that was first implemented in PHP (see here https://michelf.ca/projects/php-markdown/extra/#table)
- 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)
**'|' 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
# 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.
There is no Planet B.
pgsql-hackers by date: