Обсуждение: psql HTML mode - quoting HTML characters

Поиск
Список
Период
Сортировка

psql HTML mode - quoting HTML characters

От
"Nicholson, Brad (Toronto, ON, CA)"
Дата:
Hi,

How do I quote characters like < and > in psql's HTML mode?

For example:


Regular mode:
postgres=# select '<a href=http://www.postgresql.org>Postgres</a>';
                    ?column?
------------------------------------------------
 <a href=http://www.postgresql.org>Postgres</a>
(1 row)

HTML mode:
postgres=# \H
Output format is html.
postgres=# select '<a href=http://www.postgresql.org>Postgres</a>';
<table border="1">
  <tr>
    <th align="center">?column?</th>
  </tr>
  <tr valign="top">
    <td align="left"><a href=http://www.postgresql.org>Postgres</a></td>
  </tr>
</table>
<p>(1 row)<br />
</p>


I would like the line

<td align="left"><a href=http://www.postgresql.org>Postgres</a></td>

To be

<td align="left<a href=http://www.postgresql.org>Postgres</a></td>

Thanks,
Brad

Re: psql HTML mode - quoting HTML characters

От
Josh Kupershmidt
Дата:
On Wed, Oct 26, 2011 at 3:51 PM, Nicholson, Brad (Toronto, ON, CA)
<bnicholson@hp.com> wrote:
> How do I quote characters like < and > in psql's HTML mode?

From a brief look at print_html_text() and html_escaped_print() in
psql's print.c, I don't see any way to tell psql not to escape some
block of text in HTML print mode.

Out of curiosity, what do you find psql's HTML mode useful for?

Josh

Re: psql HTML mode - quoting HTML characters

От
"Nicholson, Brad (Toronto, ON, CA)"
Дата:
> -----Original Message-----
> From: Josh Kupershmidt [mailto:schmiddy@gmail.com]
> Sent: Wednesday, October 26, 2011 5:04 PM
> To: Nicholson, Brad (Toronto, ON, CA)
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] psql HTML mode - quoting HTML characters
>
> On Wed, Oct 26, 2011 at 3:51 PM, Nicholson, Brad (Toronto, ON, CA)
> <bnicholson@hp.com> wrote:
> > How do I quote characters like < and > in psql's HTML mode?
>
> From a brief look at print_html_text() and html_escaped_print() in
> psql's print.c, I don't see any way to tell psql not to escape some
> block of text in HTML print mode.

Darn.  Thanks though.

> Out of curiosity, what do you find psql's HTML mode useful for?

Quick and dirty reporting.  Set the HTML mode, run a query, and dump the output into Apache's document directory and
youhave a very quick, albeit crude way to present results. 

Brad.