Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<pre> shouldn't render a final trailing newline #26754

Open
jdm opened this issue Jun 2, 2020 · 2 comments
Open

<pre> shouldn't render a final trailing newline #26754

jdm opened this issue Jun 2, 2020 · 2 comments
Labels

Comments

@jdm
Copy link
Member

@jdm jdm commented Jun 2, 2020

As part of the work in #26440, I discovered some surprising behaviour about <pre>. Given:

<pre>hello</pre>

<pre>hello
</pre>

<pre>hello

</pre>

In other browsers, only the final example with two newlines renders an empty line below hello. In the initial implementation in #26447, Servo renders an empty line for the second case as well. I have not been able to find spec text in https://drafts.csswg.org/css-text-3/ that explains why other browsers behave the way they do.

I've been reading:

cc @SimonSapin

@jdm jdm added the A-layout/2020 label Jun 2, 2020
@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Jun 2, 2020

I’ll look some more, but the first thing I tried is the same happens with <div> + white-space: pre instead of <pre>. This excludes anything at the HTML parser level and indicates that this is happening at the CSS layout level.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/8160

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Jun 2, 2020

It also happens with other kinds of forced line breaks. At most one trailing break is removed/ignored.

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/8163

<p>hello</p>
<p>hello<br></p>
<p>hello<br><br></p>
<style>p { border: solid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.