Skip to content

[css-text] What are the language-defined segment breaks for HTML? #5147

Closed

Description

@SimonSapin

https://drafts.csswg.org/css-text/#white-space

Except where specified otherwise, White space processing in CSS affects only the document white space characters: spaces (U+0020), tabs (U+0009), and segment breaks.

https://drafts.csswg.org/css-text/#segment-break

CSS does not define document segmentation rules. Segments can be separated by a particular newline sequence (such as a line feed or CRLF pair), or delimited by some other mechanism, such as the SGML RECORD-START and RECORD-END tokens. For CSS processing, each document language–defined segment break and each line feed (U+000A) in the text is treated as a segment break, which is then interpreted for rendering as specified by the white-space property.

I understand that CSS wants to build abstractions in order to potentially support any document language, but making it the responsibility of those languages to specifically hook into those abstractions is not great as they might… not.

CTRL+F for "segment break" in the single-page version of https://html.spec.whatwg.org/ does not find anything. Does this mean that HTML does not have any language-specific segment break?

If css-text is not the right place to define this normatively it’d be helpful to point this out in a note.

Activity

  1. fantasai commented on Jun 2, 2020

    @fantasai
    Collaborator

    I think the key to that question is to look at the definition of segment break, rather than for usage of the specific term. HTML clearly treats CR, LF, and CRLF in the source as segment breaks.

    But it converts them to LF before passing to the DOM, which is then passed to CSS for formatting, and I'm not entirely clear what DOM thinks. I think it ends up defaulting to just having LF as a segment break.

  2. SimonSapin commented on Jun 2, 2020

    @SimonSapin
    ContributorAuthor

    https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream says that the input of the HTML parser must go through https://infra.spec.whatwg.org/#normalize-newlines which replaces CRLF and lone CR with LF. But the way this is written is all about moving code points around, it doesn’t attribute them much meaning.

    https://html.spec.whatwg.org/#newlines defines a "newline" term

    Newlines in HTML may be represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A LINE FEED (LF) characters, or pairs of U+000D CARRIAGE RETURN (CR), U+000A LINE FEED (LF) characters in that order.

    Presumably "in HTML" there means before preprocessing.

    I think it ends up defaulting

    Having normative spec based on defaulting, on the absence of a definition that says to do otherwise, is what I think is not great. As an implementer I don’t feel confident that there is indeed no such definition for HTML, rather than I failed to find it.

  3. fantasai commented on Dec 3, 2020

    @fantasai
    Collaborator

    @SimonSapin OK, we made some rewrites in that section that hopefully should make this interaction more clear. https://drafts.csswg.org/css-text-3/#white-space-processing Let us know if it addresses your issue!

  4. SimonSapin commented on Dec 3, 2020

    @SimonSapin
    ContributorAuthor

    The new text starting with "In the case of HTML" in 1014e0a looks good, but curiously I don’t find it in https://drafts.csswg.org/css-text-3/. This commit is also not listed in https://drafts.csswg.org/history/css-text-3/

  5. fantasai commented on Dec 9, 2020

    @fantasai
    Collaborator

    Seems to have made it to the server at this point, so closing out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions