Html: Should <ins> and <del> have `unicode-bidi: isolate`?

Created on 7 Jun 2020  Â·  12Comments  Â·  Source: whatwg/html

How about adding unicode-bidi: isolate to <ins> and <del> in the default UA stylesheet?

Test: https://jsbin.com/vebabex/edit?html,output

When crbug.com/1053838 mentioned about <ins>f</ins>i forming a ligature, I remember we have applied unicode-bidi: isolate to string literals in our code search site to fix undesired reordering, and I wonder the same should apply to <ins> and <del> too.

If this is a good change for bidi, #5594 confirmed that unicode-bidi: isolate should isolate font shaping from surrounding context, so I think doing this can solve both issues.

Thoughts?

/cc @r12a @upsuper @jfkthame @litherum

additioproposal i18n-alreq i18n-hlreq i18n-tracker needs implementer interest

All 12 comments

I don't like the fact it will make shaping to break for example in https://jsbin.com/katocurewu/edit which can be considered superfluous as I hadn't experience with something like that as MediaWiki doesn't have character by character diffs, but hmm, using a template coincidentally I've made for Wikimedia Commons here (broken in Mozilla, see this one in Chrome) it isn't that superfluous now I think more, but your case is also relatable, maybe something shouldn't UA stylesheet handle automagically however.

It's not just shaping that breaks, this could also break things like bidi mirroring (well, arguable that's a form of shaping, perhaps). Consider https://codepen.io/jfkthame/pen/zYrGbPo for example: applying unicode-bidi: isolate to the <ins> and <del> elements causes them to render the wrong glyphs.

A better solution for the reported chromium issue would be to use ::before and ::after to insert ZWNJ each side of the <ins> or <del> element, if it is important to maintain separate coloring (though this would still break shaping in Ebrahim's example). I don't think this should be part of the default UA stylesheet, but a site that cares more about per-character color than about shaping might choose to do it.

  • The HTML spec (https://html.spec.whatwg.org/#non-replaced-elements) says which elements should get unicode-bidi:isolate. INS and DEL are not among them. Thus, regardless of whether we think it's a good idea or not, their styling should not be changed until the HTML spec says so.

  • IMO, it's probably a good idea for DEL, since the element is supposed to mean that that text is being deleted. Thus, it should not influence the display of the surrounding characters, and leave them looking as similar as possible to what they will look like when the text in the DEL is gone. By the same token, it is not a good idea for INS: the text is being inserted, and should therefore affect the display of the surrounding text as it would if the INS were removed (and the text inside it left behind).

@aharon-lanin I suspect you might have missed that this is the repository to discuss changes to that standard. 😉

Indeed! LOL. Of course I knew that, and just wanted to score brownie points by pointing out the importance of standards compliance :)

Thank you for all the feedback. With the feedback, I added some more test cases: https://jsbin.com/vebabex/edit?html,output

Without knowing what's more natural to bidi users, some seems to be more reasonable with isolate, some without isolate. It might vary by whether it's a code (and thus RTL characters appear only as string literals) or a document (such as wikipedia). And it might vary by whether it's inline diff or side-by-side diff. If the desired behavior depends on content, as @ebraminio said, maybe this should be up to page authors.

@jfkthame Bidi mirroring is a good point we should also consider. If the consensus is not to add isolate to <ins> and <del>, agree, inserting ZWNJ would be a good solution for ligatures.

How does people think on @aharon-lanin's idea to add only to <del>?

How does people think on @aharon-lanin's idea to add only to ?

I can see how it'd make sense in some cases, at least, but I'm not sure it's universally good, and I'm uneasy about <ins> and <del> behaving differently by default; ISTM this would be quite surprising for authors.

So at the moment, my feeling is that all these ideas are things that an author could specify if they're considered suitable for their use case, but not put into the default stylesheet.

Found an interesting test case using Fira Code:
https://jsbin.com/dupelal/edit?html,output

Note that treating del as an isolate, but not treating ins as an isolate,
as I suggested, would also fix this test case.

On Wed, Jun 24, 2020 at 2:33 PM Koji Ishii notifications@github.com wrote:

Found an interesting test case using Fira Code:
https://jsbin.com/dupelal/edit?html,output

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/whatwg/html/issues/5611#issuecomment-648765575, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAIUIRGMGWF3TKPEOLX5NRTRYHP73ANCNFSM4NXMBY3Q
.

As would inserting a control using del::before and del::after to block the ligation.

(As it happens, inserting ZWNJ doesn't actually work with Fira Code; its "ligature" rules don't respect this. But other options such as ZWSP or Word Joiner do work to block it.)

Generally speaking, when x should not affect the display of the surrounding
text, you do not want it to affect it by ligating with surrounding text or
by bidi effects. Using ZWNJ (or whatever) prevents ligatures, but it does
not prevent bidi effects. On the other hand, unicode-bidi:isolate, as
implemented on the main browsers, does prevent ligatures. According to
my first statement, that is beneficial, generally speaking. Nevertheless,
from a purist point of view, unicode-bidi:isolate was never intended to
affect ligatures, and that it does at first comes as a surprise. Browsers
could, in principle, also change their behavior in this respect as long as
the correct behavior isn't specified.

Thus, once again from a purist point of view, wherever we have
unicode-bidi:isolate by default, putting something explicit to prevent
ligatures would also make sense.

Putting something that prevents ligatures without unicode-bidi:isolate is
not a good idea.

On Wed, Jun 24, 2020 at 3:51 PM jfkthame notifications@github.com wrote:

As would inserting a control using del::before and del::after to block
the ligation.

(As it happens, inserting ZWNJ doesn't actually work with Fira Code; its
"ligature" rules don't respect this. But other options such as ZWSP or Word
Joiner do work to block it.)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/whatwg/html/issues/5611#issuecomment-648800100, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAIUIRDTUINK3CJ56ZENZ3LRYHZFLANCNFSM4NXMBY3Q
.

FWIW, I agree with @jfkthame’s points here, and would also recommend no change to the spec.

Was this page helpful?
0 / 5 - 0 ratings