Closed Bug 389595 Opened 17 years ago Closed 17 years ago

Don't break around '(' and ')'

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

from bug 95067 comment 137: I think that the cases is imprtand for Western language users: colo(u)ring bug(s). Now, the parentheses are breakable characters, I think that this rule is good for other cases. But we should not break on above cases. For the fixing it, we should check the sentence. 1. If GetJISx4051Breaks finds class 1, check whether the character needs special handling. i.e., (cur == '(') 2. If we find it, save the position (*A) 3. If we find non-character && non-numeric && non-close parenthesis, reset current process. 4. If we find close parenthesis, clear the breakable flag of (*A). And don't break after this too. I.e., We cannot save following case: foo(ba-r). foo(e.g., bar). But I think that it is enough.
That could be complex. How about nested parentheses? What are the cases where we *should* break before/after parentheses?
er, we should also check the previous character of '(', it should be character or numeric. (In reply to comment #1) > That could be complex. How about nested parentheses? I think that only the most descendant parentheses should be saved. e.g., foo(bar(s)) Is this case often you can see? # If this is a source code, it should be styled as white-space: nowrap; if the breaking should not be. > What are the cases where we *should* break before/after parentheses? fmm.. shouldn't we break following cases? (it only needs narrow width case??) foooooo(baaaaar baaaaaar). as: foooooo (baaaaaar baaaaaar). # And compatibility with IE7.
In English, at least, you should put a space before the opening parenthesis and a space or punctuation after the closing parenthesis. If English was the main concern, I'd say don't break around parentheses.
In Japanese, we don't use space between characters. But most Japanese characters are breakable. So, even if they are new class [c] of bug 389056, Japanese users might not have trouble.
er, o.k. # If other language users have objection, please comment here.
Status: NEW → ASSIGNED
Depends on: 389056
Summary: Don't break around '(' and ')' if it only has one word → Don't break around '(' and ')'
In Western scripts, line-break opportunities are basically marked with spaces. Additional break opportunities may be marked with hyphens (and sometimes with dashes). Breaking in _any_ other place would generally be unconventional and usually confusing. This is actually clearly expressed also in UAX #14 (although it does not mention dashes).[1] Unfortunately, UAX #14 confuses this rather simple principle by continuing to describe the behavior of various characters in a very complicated way. I was stunned when I read (in the third section of table 1) that closing punctuation -- such as ')' -- prohibits line-breaks before, and that opening punctuation -- such as '(' -- prohibits line-breaks after.[2] This seemed to suggest that a line-break is allowed _before_ an opening punctuation and _after_ a closing punctuation. After a while, however, I realized that all it tries to say is: "Do not break after the spaces in situations such as ( this ) where there are extra spaces separating the parentheses from their contents." It does not speak anything about how to break _outside_ the parentheses, but only how to not break _inside_ them. Perhaps it is exactly this confusing description in UAX #14 that has tricked even the IE designers to allow line-breaks before and after parentheses, regardless of whether there are spaces around the parentheses or not. For Latin scripts, linebreaking would really be rather simple if UAX #14 just said (as I have tried to explain in bug 95067) that the only legal break opportunities are after spaces, hyphens and dashes, and breaking anywhere else would be exceptional. [1] http://www.unicode.org/reports/tr14/#BreakOpportunities [2] http://www.unicode.org/reports/tr14/#Table1
The problem is that in the absence of reliable language information, and the presence of a great deal of non-natural language, assuming everything is Western or English is not necessarily the best strategy.
Defaulting to a very restrictive breaking policy such as you suggest might still be a good thing ... we need more data.
In the current patch (attachment 273944 [details] [diff] [review] rv2.0pre3), '(' and ')' are not breakable if the around characters are 'character' or 'numeric' class. But if they are CJK characters, they are 'open parenthesis' and 'close parenthesis' class.
(In reply to comment #2) > > What are the cases where we *should* break before/after parentheses? > > fmm.. shouldn't we break following cases? (it only needs narrow width case??) > > foooooo(baaaaar baaaaaar). > > as: > > foooooo > (baaaaaar > baaaaaar). > In Spanish, just like in English, you need to put an space right before the open parentheses and either an space, or a punctuation mark right after the close parentheses. So the above example wouldn't happen in correctly written Spanish paragraph. However, I see that example as a typical layout for programming language code. I, for one, would like NOT to see a break between fooooo and baaaaar, wherever the open parenthesis may be placed: Example: main(String args[]) RIGHT: main(String args[]) WRONG: main( String args[]) main (String args[]) main(String args []) main(String args [ ]) Just in the case it may be useful, two relevant points in the Sun Java Code Conventions: http://java.sun.com/docs/codeconv/html/CodeConventions.doc3.html#248 http://java.sun.com/docs/codeconv/html/CodeConventions.doc5.html#381 JM2C
fixed by the checked-in for bug 389056.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.