Discussion:
[Docutils-users] HTML writer: initial EOL after <pre>
Alan Isaac
2016-08-11 15:53:43 UTC
Permalink
There is a major docutils component to this question, but I also
ask for CSS help.

Default browser styling of a PRE element is something like this::

display: block;
font-family: monospace;
white-space: pre;

The white-space appears to be interpreted by many browsers as
including any EOL immediately following the tag. ::

<pre>
So this appears to be preceded by an empty line.
</pre>

That seems to be typical handling, although not in Edge.
If I am right, it conflicts with the spec:
https://www.w3.org/TR/html4/appendix/notes.html#notes-line-breaks
Finding a browser error admittedly seems unlikely ...
But if I am wrong, it should be possible to style it away.

1. Is this a browser bug?

2. If not, this behavior can be styled away. How?
And should this "fixed" styling be done by the writer.

3. If styling is not a solution, should PRE elements be written
with content following immediately (rather than with
an initial EOL)?

Cheers,
Alan



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Guenter Milde
2016-08-13 10:29:59 UTC
Permalink
Post by Alan Isaac
There is a major docutils component to this question, but I also
ask for CSS help.
display: block;
font-family: monospace;
white-space: pre;
The white-space appears to be interpreted by many browsers as
<pre>
So this appears to be preceded by an empty line.
</pre>
That seems to be typical handling, although not in Edge.
https://www.w3.org/TR/html4/appendix/notes.html#notes-line-breaks
Finding a browser error admittedly seems unlikely ...
This is the "normal" rule. It conflicts with the definition of
``white-space:pre``: "don't ignore whitespace".

Also, the definition for XHTML may differ.
Post by Alan Isaac
But if I am wrong, it should be possible to style it away.
1. Is this a browser bug?
Unsure, see above.
Post by Alan Isaac
2. If not, this behavior can be styled away. How?
And should this "fixed" styling be done by the writer.
Not that I know of. Maybe with some exoticly complicated rule...
Post by Alan Isaac
3. If styling is not a solution, should PRE elements be written
with content following immediately (rather than with
an initial EOL)?
I think so. This is what the "html5" writer does.

Günter


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Pl
Alan G. Isaac
2016-08-14 12:53:34 UTC
Permalink
Post by Guenter Milde
Post by Alan Isaac
3. If styling is not a solution, should PRE elements be written
with content following immediately (rather than with
an initial EOL)?
On 8/13/2016 6:29 AM, Guenter Milde wrote:>
Post by Guenter Milde
I think so. This is what the "html5" writer does.
I found this explanation:
http://stackoverflow.com/questions/17722951/difference-in-display-between-html-and-xhtml
It seems from this explanation that the XHTML writers
should not write an extra EOL immediately after a PRE tag,
but it should not matter for HTML 5.

fwiw,
Alan

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Docutils-users mailing list
Docutils-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
Guenter Milde
2016-08-14 18:30:11 UTC
Permalink
Post by Alan G. Isaac
Post by Guenter Milde
Post by Alan Isaac
3. If styling is not a solution, should PRE elements be written
with content following immediately (rather than with
an initial EOL)?
On 8/13/2016 6:29 AM, Guenter Milde wrote:>
Post by Guenter Milde
I think so. This is what the "html5" writer does.
http://stackoverflow.com/questions/17722951/difference-in-display-between-html-and-xhtml
It seems from this explanation that the XHTML writers
should not write an extra EOL immediately after a PRE tag,
but it should not matter for HTML 5.
Yes. However, to be on the safe side, the "html5-plain" writer writes
"polyglott" HTML that is also valid XML.

Günter

Loading...