Skip to content

[css-line-breaking] Soft-break vs. <br>, inside embedded opposiate directional run  #5121

Closed

Description

@ntounsi

section-5 (https://drafts.csswg.org/css-text-3/#line-breaking) talks about soft and forced line break but says nothing about the effect, i.e. the rendering. Is it the same in both cases? That is, if a line is wrapped at some place, should the resulting lines appear as if it was a forced break at the same place?

As for bidi texts, if a line break occurs inside a phrase that is progressing in opposite direction, wrt the surrounding context, the break (rightfully) does not end the "embedded" base direction, unlike HTML <br>.
As a consequence, if the next line begins with a directionally ambiguous character, the rest of the phrase takes the global opposite base direction.
Example (in RTL context):

lineBreak
The 1st two lines result from a text wrapped (soft-break) before the number 2. The whole Latin string flows LTR. Then the same text with forced-break at the same position. In the last line, the rest of the Latin string flows RTL.

Looks odd to me.

Source:

<div  dir="rtl" style="width: 50%;">
 <p>
 تحدثنا وقالت في لغتها: 
 « I should be living at 2, Atlas street</span> »
 ثم ذهبت. 
 </p>
 <p>
 تحدثنا وقالت في لغتها: 
 « I should be living at<br> 2, Atlas street</span> »
 ثم ذهبت. 
 </p>
</div>

note <br> before 2 in the second <p>.

Can CSS line breaking spec/rules consider such case (or similar)? I didn't see that in the document.
Or simply indicate in the first para of section-5 (https://drafts.csswg.org/css-text-3/#line-breaking), that forced break and soft break occurring at the same point, may have differences in rendering for some scripts (or something like).

Activity

  1. fantasai commented on May 27, 2020

    @fantasai
    Collaborator

    Soft wraps have LS behavior, whereas forced breaks have PS behavior. The rendering should otherwise be the same. I think Writing Modes is pretty clear about the latter point (https://www.w3.org/TR/css-writing-modes-3/#bidi-algo) but maybe css-text-3 need to be clearer about the former.

  2. ntounsi commented on Jun 11, 2020

    @ntounsi
    Author

    My point was: is this difference in rendering something that needs to be resolved? (OK, it is a very special case).

    For example line-break property could have one of its values :

    • prevents wrap before a digit in general (or bidirectionally ambiguous chars). Or simply say that it is not a soft wrap opportunity.
    • ends embedded opposite directional run, as it is the case with <br>.
  3. kojiishi commented on Jun 11, 2020

    @kojiishi
    Contributor

    Using <div> instead of <br> shows the same result.
    Test: https://output.jsbin.com/lofidec

    The bidi algorithm is defined by Unicode UAX #9 UNICODE BIDIRECTIONAL ALGORITHM. It resolves the bidi level for each paragraph, so if a paragraph is split into two, the algorithm may compute different results.

    In the "Status" section of the UAX#9, there's a link to the feedback form. If you feel there's a room to improve the algorithm, please feedback to Unicode.

  4. ntounsi commented on Jun 17, 2020

    @ntounsi
    Author

    Yes okay, <br> acts as a paragraph separator, hence the result.

    However, since there is linebreaking processing model being discussed in CSS (§5), why not take this opportunity to try to do something for this specific problem.

  5. fantasai commented on Jul 1, 2020

    @fantasai
    Collaborator

    @ntounsi line-break controls soft wrap opportunities. And none of these create a bidi paragraph break. So I don't understand your comment #5121 (comment)

  6. ntounsi commented on Jul 1, 2020

    @ntounsi
    Author

    @fantasai Sorry, I may have misspoke. Forget about Bidi paragraph break.
    I was asking if it would be possible that line-break also controls whether soft wrap opportunity will create a difference in rendering (compared to hard break).

  7. fantasai commented on Jul 2, 2020

    @fantasai
    Collaborator

    @ntounsi No, line-break is only about where break opportunities occur. It shouldn't be redefining what <br> means.

  8. fantasai commented on Jul 2, 2020

    @fantasai
    Collaborator

    Note: The application of bidi to CSS paragraph rendering is defined in https://www.w3.org/TR/css-writing-modes-3/#bidi-algo

  9. fantasai commented on Jul 2, 2020

    @fantasai
    Collaborator

    @ntounsi Added some cross-references to the relevant sections of Writing Modes and UAX9. Is there something else you wanted here, or should we close the issue?

  10. ntounsi commented on Jul 2, 2020

    @ntounsi
    Author

    @ntounsi No, line-break is only about where break opportunities occur.

    My question was also to know roughly if a break opportunity should not occur before a bidi-ambiguous character for example.

  11. ntounsi commented on Jul 2, 2020

    @ntounsi
    Author

    @fantasai Thank you for clarifications and the editorial change.

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