Documentation
¶
Overview ¶
bidi implements the Unicode Bidi algorithm.
The implementation is inspired by x/text/unicode/bidi, providing a similar API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
type Level int8
Level is the embedding level of a character. Even embedding levels indicate left-to-right order and odd levels indicate right-to-left order.
type Paragraph ¶
type Paragraph struct {
// contains filtered or unexported fields
}
Paragraph is the main entry point of the package.
It stores internal data required to segment a string, and should be reused to reduce allocations.
func (*Paragraph) Segment ¶
Segment applies the Bidi algorithm. The returned runs are only valid until the next call to [Segment], [SegmentString] or [SegmentBytes].
[defaultDirection] is the default direction for the input text. The direction is overridden if the text contains directional characters.
func (*Paragraph) SegmentBytes ¶
SegmentBytes is the same as [Segment], but avoid allocations if [text] is a byte slice.
type Run ¶
type Run struct {
// Start and End indicate the subslice of the input text : text[Start:End]
Start, End int
Level Level
}
Run is a slice of text with a constant direction.
func (Run) IsLeftToRight ¶
IsLeftToRight returns `true` for a RTL run.