Add in-house Bidi segmentation#251
Conversation
…tests, regarding whitespaces handling.
whereswaldon
left a comment
There was a problem hiding this comment.
Wow, this is quite the PR. I see the logic of vendoring an implementation of this. I agree that upstream isn't really working on it, and you're quite right that it's impossible for us to fix our handling of embedding levels without exposing them.
Thanks for tackling this.
|
(Waiting for @andydotxyz review since there is a significant API addition.) |
|
Apologies, I have been snowed under. In some situations I have had to provide a bridge implementation so that apps can "replace" to get the new code under the old import - but that may have been CGo problem or complications we don't have to worry about here... |
I don't expect such limations, especially since our use of x/text/bidi was completely internal. Your are right however that there will likely be two copies of similar code in the binary, if the user performs directional string manipulations. |
andydotxyz
left a comment
There was a problem hiding this comment.
Great thanks for that and thinking through the implications too.
We currently rely on the semi standard
x/text/unicode/bidipackage for Bidi segmentation. It has served us quite well so far, but :See golang/go#71809, golang/go#69819 and golang/go#67098
I propose to include a fork of the
x/text/unicode/bidiin our repo, as implemented in this branch. The API is simplified and the case of []rune as input is supported. This implementation passes the Unicode conformance tests.Also, it exposes the Bidi level, which will probably be required to properly reorder nested bidi texts (see #249).
What do you think ?