On Wed, 18 Nov 2026 17:13:17 GMT, Andy Goryachev <[email protected]> wrote:
>> modules/jfx.incubator.richtext/src/main/java/com/sun/jfx/incubator/scene/control/richtext/HtmlStyledOutput.java
>> line 399:
>>
>>> 397: wr.write("<body>\n");
>>> 398: if (font != null) {
>>> 399: wr.write("<pre>");
>>
>> HTML strips the first newline after a `<pre>`, so this will get rid of an
>> intentional newline at the beginning of the content.
>>
>> Suggestion:
>>
>> wr.write("<pre>\n");
>
> I am not sure this is a valid finding - `"<pre>"` actually adds a newline in
> MS Word since the newline is inside `<pre>`.
It's a valid finding for browsers that read HTML, even if Word handles it
differently. HTML discards a single newline immediately after the opening
`<pre>`. The exporter needs to account for this in order to preserve a leading
newline in the clipboard when exporting it to HTML. See [the w3c pre element
spec](https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html#the-pre-element).
Both of the following two chunks of HTML will display the text without a
leading newline:
<pre style="display: inline-block; border: 1px solid #666; margin: 0; padding:
0;">This will be the first line</pre>
and
<pre style="display: inline-block; border: 1px solid #666; margin: 0; padding:
0;">
This will also be the first line, not the second</pre>
The following will display a single newline before "This will be the second
line"
<pre style="display: inline-block; border: 1px solid #666; margin: 0; padding:
0;">
This will be the second line</pre>
You can see this in the browser of your choice.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2369#discussion_r4619138559