Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text/unicode/bidi: API not implemented but code works fine #42356

Closed
pgundlach opened this issue Nov 3, 2020 · 2 comments
Closed

x/text/unicode/bidi: API not implemented but code works fine #42356

pgundlach opened this issue Nov 3, 2020 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@pgundlach
Copy link
Contributor

What version of Go are you using (go version)?

$ go version go1.15.3 darwin/amd64

The code in unicode/bidi is working fine (as far as I can see), but there is no user level API available, though it is documented. See https://pkg.go.dev/golang.org/x/text/unicode/bidi for example. All methods are unimplemented (panic()).

I suggest to change the API slightly to avoid panics in the library (should be errors instead) and perhaps to clarify the parameters. For example the func (*Paragraph) Line could mention if the start and end parameters are given in bytes or runes.

I am working on an implementation of the API and my question is: is it worth issuing a pull request or is the API left out on purpose?

Would it be okay to remove the panics and return errors instead?

My background is that I am using the bidi algorithm of my TeX based typesetting system and currently just pulling in the relevant files.

@gopherbot gopherbot added this to the Unreleased milestone Nov 3, 2020
@toothrot toothrot changed the title x/text: unicode/bidi API not implemented but code works fine x/text/unicode/bidi: API not implemented but code works fine Nov 3, 2020
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 3, 2020
@toothrot
Copy link
Contributor

toothrot commented Nov 3, 2020

/cc @mpvl

@gopherbot
Copy link

Change https://golang.org/cl/267857 mentions this issue: text/unicod/bidi: implement API, remove panics

@golang golang locked and limited conversation to collaborators Nov 24, 2021
xhit pushed a commit to xhit/text that referenced this issue Oct 10, 2022
The bidi API splits strings with mixed left-to-right (ltr) and
right-to-left (rtl) parts into substrings (segments). Each segment
contains a substring, a direction of text flow (either ltr or rtl)
and the start and end positions in the input.

The paragraph validators do not panic, instead the newParagraph function
returns an error message in case the input is invalid.

Fixes golang/go#42356

Change-Id: I90cafc8fadb0cf6936dfb1ab373586017147d709
Reviewed-on: https://go-review.googlesource.com/c/text/+/267857
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants