strange para/programlisting pattern in sgml docs

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: strange para/programlisting pattern in sgml docs
Date: 2023-11-25 20:44:38
Message-ID: b9981380-541d-de32-cd7c-622269ac3be4@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

while working on a patch I noticed we do this in the SGML docs (for
example in indexam.sgml and a bunch of other files):

<para>
... some text ...
</para>

<para>
<programlisting>
some code
</programlisting>
... description of the code.
</para>

That is, the program listing is in a paragraph that starts immediately
before it. I just noticed this ends up like this in the HTML:

<p>... some text ...</p>

<p></p>

<pre>some code</pre>

<p>... description of the code.</p>

That is, there's an empty <p></p> before <pre>, which seems a bit weird,
but it seems to render fine (at least in Firefox), so maybe it looks
weird but is not a problem in practice ...

I did search for what (X)HTML says about this, and the only thing I
found is HTML5 flow control section [1], which says

... elements whose content model allows any flow content should
have either at least one descendant text node ...

Ofc, we're rendering into XHTML, not HTML5. However, W3 advises against
this in the HTML4.0 document too [2]:

We discourage authors from using empty P elements. User agents
should ignore empty P elements.

So it might be "OK" because browsers ignore those elements, but maybe we
should stop doing that anyway?

regards

[1]
https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#flow-content-0

[2] https://www.w3.org/TR/1998/REC-html40-19980424/struct/text.html#h-9.3.1

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Zubkov 2023-11-25 20:45:41 Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements
Previous Message Tomas Vondra 2023-11-25 20:06:03 Re: brininsert optimization opportunity