bidi

Imports

Imports #

"bytes"
"container/list"
"fmt"
"sort"
"fmt"
"log"
"unicode/utf8"

Constants & Variables

AL const #

const AL

AN const #

const AN

B const #

const B

BN const #

const BN

CS const #

const CS

Control const #

const Control

EN const #

const EN

ES const #

const ES

ET const #

const ET

FSI const #

const FSI

L const #

const L Class = iota

LRE const #

const LRE

LRI const #

const LRI

LRO const #

const LRO

LeftToRight const #

LeftToRight indicates the text contains no right-to-left characters and that either there are some left-to-right characters or the option DefaultDirection(LeftToRight) was passed.

const LeftToRight Direction = iota

Mixed const #

Mixed indicates text contains both left-to-right and right-to-left characters.

const Mixed

NSM const #

const NSM

Neutral const #

Neutral means that text contains no left-to-right and right-to-left characters and that no default direction has been set.

const Neutral

ON const #

const ON

PDF const #

const PDF

PDI const #

const PDI

R const #

const R

RLE const #

const RLE

RLI const #

const RLI

RLO const #

const RLO

RightToLeft const #

RightToLeft indicates the text contains no left-to-right characters and that either there are some right-to-left characters or the option DefaultDirection(RightToLeft) was passed.

const RightToLeft

S const #

const S

UnicodeVersion const #

UnicodeVersion is the Unicode version from which the tables in this package are derived.

const UnicodeVersion = "12.0.0"

UnicodeVersion const #

UnicodeVersion is the Unicode version from which the tables in this package are derived.

const UnicodeVersion = "11.0.0"

UnicodeVersion const #

UnicodeVersion is the Unicode version from which the tables in this package are derived.

const UnicodeVersion = "15.0.0"

UnicodeVersion const #

UnicodeVersion is the Unicode version from which the tables in this package are derived.

const UnicodeVersion = "13.0.0"

UnicodeVersion const #

UnicodeVersion is the Unicode version from which the tables in this package are derived.

const UnicodeVersion = "10.0.0"

UnicodeVersion const #

UnicodeVersion is the Unicode version from which the tables in this package are derived.

const UnicodeVersion = "9.0.0"

WS const #

const WS

bidiIndex var #

bidiIndex: 24 blocks, 1536 entries, 1536 bytes Block 0 is the zero block.

var bidiIndex = [1536]uint8{...}

bidiIndex var #

bidiIndex: 24 blocks, 1536 entries, 1536 bytes Block 0 is the zero block.

var bidiIndex = [1536]uint8{...}

bidiIndex var #

bidiIndex: 24 blocks, 1536 entries, 1536 bytes Block 0 is the zero block.

var bidiIndex = [1536]uint8{...}

bidiIndex var #

bidiIndex: 24 blocks, 1536 entries, 1536 bytes Block 0 is the zero block.

var bidiIndex = [1536]uint8{...}

bidiIndex var #

bidiIndex: 26 blocks, 1664 entries, 3328 bytes Block 0 is the zero block.

var bidiIndex = [1664]uint16{...}

bidiIndex var #

bidiIndex: 24 blocks, 1536 entries, 1536 bytes Block 0 is the zero block.

var bidiIndex = [1536]uint8{...}

bidiValues var #

bidiValues: 259 blocks, 16576 entries, 16576 bytes The third block is the zero block.

var bidiValues = [16576]uint8{...}

bidiValues var #

bidiValues: 240 blocks, 15360 entries, 15360 bytes The third block is the zero block.

var bidiValues = [15360]uint8{...}

bidiValues var #

bidiValues: 234 blocks, 14976 entries, 14976 bytes The third block is the zero block.

var bidiValues = [14976]uint8{...}

bidiValues var #

bidiValues: 228 blocks, 14592 entries, 14592 bytes The third block is the zero block.

var bidiValues = [14592]uint8{...}

bidiValues var #

bidiValues: 248 blocks, 15872 entries, 15872 bytes The third block is the zero block.

var bidiValues = [15872]uint8{...}

bidiValues var #

bidiValues: 222 blocks, 14208 entries, 14208 bytes The third block is the zero block.

var bidiValues = [14208]uint8{...}

bpClose const #

const bpClose

bpNone const #

const bpNone bracketType = iota

bpOpen const #

const bpOpen

controlByteToClass var #

var controlByteToClass = [16]Class{...}

implicitLevel const #

const implicitLevel level = *ast.UnaryExpr

maxDepth const #

const maxDepth = 125

maxPairingDepth const #

const maxPairingDepth = 63

numClass const #

const numClass

openMask const #

const openMask = 0x10

trie var #

var trie = *ast.CallExpr

unknownClass const #

const unknownClass = *ast.UnaryExpr

xorMaskShift const #

const xorMaskShift = 5

xorMasks var #

xorMasks contains masks to be xor-ed with brackets to get the reverse version.

var xorMasks = []int32{...}

xorMasks var #

xorMasks contains masks to be xor-ed with brackets to get the reverse version.

var xorMasks = []int32{...}

xorMasks var #

xorMasks contains masks to be xor-ed with brackets to get the reverse version.

var xorMasks = []int32{...}

xorMasks var #

xorMasks contains masks to be xor-ed with brackets to get the reverse version.

var xorMasks = []int32{...}

xorMasks var #

xorMasks contains masks to be xor-ed with brackets to get the reverse version.

var xorMasks = []int32{...}

xorMasks var #

xorMasks contains masks to be xor-ed with brackets to get the reverse version.

var xorMasks = []int32{...}

Type Aliases

Class type #

Class is the Unicode BiDi class. Each rune has a single class.

type Class uint

Direction type #

A Direction indicates the overall flow of text.

type Direction int

Option type #

An Option is an option for Bidi processing.

type Option func(*options)

bracketPairs type #

bracketPairs is a slice of bracketPairs with a sort.Interface implementation.

type bracketPairs []bracketPair

bracketType type #

Bidi_Paired_Bracket_Type BD14. An opening paired bracket is a character whose Bidi_Paired_Bracket_Type property value is Open. BD15. A closing paired bracket is a character whose Bidi_Paired_Bracket_Type property value is Close.

type bracketType byte

level type #

level is the embedding level of a character. Even embedding levels indicate left-to-right order and odd levels indicate right-to-left order. The special level of -1 is reserved for undefined order.

type level int8

Structs

Ordering struct #

An Ordering holds the computed visual order of runs of a Paragraph. Calling SetBytes or SetString on the originating Paragraph invalidates an Ordering. The methods of an Ordering should only be called by one goroutine at a time.

type Ordering struct {
runes [][]rune
directions []Direction
startpos []int
}

Paragraph struct #

A Paragraph holds a single Paragraph for Bidi processing.

type Paragraph struct {
p []byte
o Ordering
opts []Option
types []Class
pairTypes []bracketType
pairValues []rune
runes []rune
options options
}

Properties struct #

Properties provides access to BiDi properties of runes.

type Properties struct {
entry uint8
last uint8
}

Run struct #

A Run is a continuous sequence of characters of a single direction.

type Run struct {
runes []rune
direction Direction
startpos int
}

bidiTrie struct #

bidiTrie. Total size: 19904 bytes (19.44 KiB). Checksum: b1f201ed2debb6c8.

type bidiTrie struct {

}

bidiTrie struct #

bidiTrie. Total size: 16128 bytes (15.75 KiB). Checksum: 8122d83e461996f.

type bidiTrie struct {

}

bidiTrie struct #

bidiTrie. Total size: 16512 bytes (16.12 KiB). Checksum: 2a9cf1317f2ffaa.

type bidiTrie struct {

}

bidiTrie struct #

bidiTrie. Total size: 17408 bytes (17.00 KiB). Checksum: df85fcbfe9b8377f.

type bidiTrie struct {

}

bidiTrie struct #

bidiTrie. Total size: 16896 bytes (16.50 KiB). Checksum: 6f0927067913dc6d.

type bidiTrie struct {

}

bidiTrie struct #

bidiTrie. Total size: 15744 bytes (15.38 KiB). Checksum: b4c3b70954803b86.

type bidiTrie struct {

}

bracketPair struct #

bracketPair holds a pair of index values for opening and closing bracket location of a bracket pair.

type bracketPair struct {
opener int
closer int
}

bracketPairer struct #

type bracketPairer struct {
sos Class
openers *list.List
pairPositions bracketPairs
codesIsolatedRun []Class
indexes []int
}

directionalStatusStack struct #

This stack will store the embedding levels and override and isolated statuses

type directionalStatusStack struct {
stackCounter int
embeddingLevelStack [*ast.BinaryExpr]level
overrideStatusStack [*ast.BinaryExpr]Class
isolateStatusStack [*ast.BinaryExpr]bool
}

isolatingRunSequence struct #

type isolatingRunSequence struct {
p *paragraph
indexes []int
types []Class
resolvedLevels []level
level level
sos Class
eos Class
}

options struct #

type options struct {
defaultDirection Direction
}

paragraph struct #

A paragraph contains the state of a paragraph.

type paragraph struct {
initialTypes []Class
pairTypes []bracketType
pairValues []rune
embeddingLevel level
resultTypes []Class
resultLevels []level
matchingPDI []int
matchingIsolateInitiator []int
}

Functions

AppendReverse function #

AppendReverse reverses the order of characters of in, appends them to out, and returns the result. Modifiers will still follow the runes they modify. Brackets are replaced with their counterparts.

func AppendReverse(out []byte, in []byte) []byte

Bytes method #

Bytes returns the text of the run in its original order.

func (r *Run) Bytes() []byte

Class method #

Class returns the Bidi class for p.

func (p Properties) Class() Class

DefaultDirection function #

DefaultDirection sets the default direction for a Paragraph. The direction is overridden if the text contains directional characters.

func DefaultDirection(d Direction) Option

Direction method #

Direction reports the direction of the run.

func (r *Run) Direction() Direction

Direction method #

Direction reports the directionality of the runs. The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.

func (o *Ordering) Direction() Direction

Direction method #

Direction returns the direction of the text of this paragraph. The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.

func (p *Paragraph) Direction() Direction

IsBracket method #

IsBracket reports whether the rune is a bracket.

func (p Properties) IsBracket() bool

IsLeftToRight method #

IsLeftToRight reports whether the principle direction of rendering for this paragraphs is left-to-right. If this returns false, the principle direction of rendering is right-to-left.

func (p *Paragraph) IsLeftToRight() bool

IsOpeningBracket method #

IsOpeningBracket reports whether the rune is an opening bracket. IsBracket must return true.

func (p Properties) IsOpeningBracket() bool

Len method #

func (i *isolatingRunSequence) Len() int

Len method #

func (p *paragraph) Len() int

Len method #

func (b bracketPairs) Len() int

Less method #

func (b bracketPairs) Less(i int, j int) bool

Line method #

Line computes the visual ordering of runs for a single line starting and ending at the given positions in the original text.

func (p *Paragraph) Line(start int, end int) (Ordering, error)

Lookup function #

Lookup returns properties for the first rune in s and the width in bytes of its encoding. The size will be 0 if s does not hold enough bytes to complete the encoding.

func Lookup(s []byte) (p Properties, sz int)

LookupRune function #

LookupRune returns properties for r.

func LookupRune(r rune) (p Properties, size int)

LookupString function #

LookupString returns properties for the first rune in s and the width in bytes of its encoding. The size will be 0 if s does not hold enough bytes to complete the encoding.

func LookupString(s string) (p Properties, sz int)

NumRuns method #

NumRuns returns the number of runs.

func (o *Ordering) NumRuns() int

Order method #

Order computes the visual ordering of all the runs in a Paragraph.

func (p *Paragraph) Order() (Ordering, error)

Pos method #

Pos returns the position of the Run within the text passed to SetBytes or SetString of the originating Paragraph value.

func (r *Run) Pos() (start int, end int)

ReverseString function #

ReverseString reverses the order of characters in s and returns a new string. Modifiers will still follow the runes they modify. Brackets are replaced with their counterparts.

func ReverseString(s string) string

Run method #

Run returns the ith run within the ordering.

func (o *Ordering) Run(i int) Run

RunAt method #

RunAt reports the Run at the given position of the input text. This method can be used for computing line breaks on paragraphs.

func (p *Paragraph) RunAt(pos int) Run

SetBytes method #

SetBytes configures p for the given paragraph text. It replaces text previously set by SetBytes or SetString. If b contains a paragraph separator it will only process the first paragraph and report the number of bytes consumed from b including this separator. Error may be non-nil if options are given.

func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error)

SetString method #

SetString configures s for the given paragraph text. It replaces text previously set by SetBytes or SetString. If s contains a paragraph separator it will only process the first paragraph and report the number of bytes consumed from s including this separator. Error may be non-nil if options are given.

func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error)

String method #

func (b *bracketPair) String() string

String method #

String returns the text of the run in its original order.

func (r *Run) String() string

Swap method #

func (b bracketPairs) Swap(i int, j int)

applyLevelsAndTypes method #

Applies the levels and types resolved in rules W1-I2 to the resultLevels array.

func (s *isolatingRunSequence) applyLevelsAndTypes()

assertOnly method #

Algorithm validation. Assert that all values in types are in the provided set.

func (s *isolatingRunSequence) assertOnly(codes ...Class)

assignBracketType method #

assignBracketType implements rule N0 for a single bracket pair.

func (p *bracketPairer) assignBracketType(loc bracketPair, dirEmbed Class, initialTypes []Class)

assignLevelsToCharactersRemovedByX9 method #

Assign level information to characters removed by rule X9. This is for ease of relating the level information to the original input data. Note that the levels assigned to these codes are arbitrary, they're chosen so as to avoid breaking level runs.

func (p *paragraph) assignLevelsToCharactersRemovedByX9()

calculateOrdering function #

func calculateOrdering(levels []level, runes []rune) Ordering

classBeforePair method #

classBeforePair determines which strong types are present before a Bracket Pair. Return R or L if strong type found, otherwise ON.

func (p *bracketPairer) classBeforePair(loc bracketPair) Class

classifyPairContent method #

classifyPairContent reports the strong types contained inside a Bracket Pair, assuming the given embedding direction. It returns ON if no strong type is found. If a single strong type is found, it returns this type. Otherwise it returns the embedding direction. TODO: use separate type for "strong" directionality.

func (p *bracketPairer) classifyPairContent(loc bracketPair, dirEmbed Class) Class

computeMultilineReordering function #

Return multiline reordering array for a given level array. Reordering does not occur across a line break.

func computeMultilineReordering(levels []level, linebreaks []int) []int

computeReordering function #

Return reordering array for a given level array. This reorders a single line. The reordering is a visual to logical map. For example, the leftmost char is string.charAt(order[0]). Rule L2.

func computeReordering(levels []level) []int

depth method #

func (s *directionalStatusStack) depth() int

determineExplicitEmbeddingLevels method #

Determine explicit levels using rules X1 - X8

func (p *paragraph) determineExplicitEmbeddingLevels()

determineIsolatingRunSequences method #

Definition BD13. Determine isolating run sequences.

func (p *paragraph) determineIsolatingRunSequences() []*isolatingRunSequence

determineLevelRuns method #

determineLevelRuns returns an array of level runs. Each level run is described as an array of indexes into the input string. Determines the level runs. Rule X9 will be applied in determining the runs, in the way that makes sure the characters that are supposed to be removed are not included in the runs.

func (p *paragraph) determineLevelRuns() [][]int

determineMatchingIsolates method #

determineMatchingIsolates determines the matching PDI for each isolate initiator and vice versa. Definition BD9. At the end of this function: - The member variable matchingPDI is set to point to the index of the matching PDI character for each isolate initiator character. If there is no matching PDI, it is set to the length of the input text. For other characters, it is set to -1. - The member variable matchingIsolateInitiator is set to point to the index of the matching isolate initiator character for each PDI character. If there is no matching isolate initiator, or the character is not a PDI, it is set to -1.

func (p *paragraph) determineMatchingIsolates()

determineParagraphEmbeddingLevel method #

determineParagraphEmbeddingLevel reports the resolved paragraph direction of the substring limited by the given range [start, end). Determines the paragraph level based on rules P2, P3. This is also used in rule X5c to find if an FSI should resolve to LRI or RLI.

func (p *paragraph) determineParagraphEmbeddingLevel(start int, end int) level

empty method #

func (s *directionalStatusStack) empty()

findRunLimit method #

Return the limit of the run consisting only of the types in validSet starting at index. This checks the value at index, and will return index if that value is not in validSet.

func (s *isolatingRunSequence) findRunLimit(index int, validSet ...Class) int

getLevels method #

getLevels computes levels array breaking lines at offsets in linebreaks. Rule L1. The linebreaks array must include at least one value. The values must be in strictly increasing order (no duplicates) between 1 and the length of the text, inclusive. The last value must be the length of the text.

func (p *paragraph) getLevels(linebreaks []int) []level

getReordering method #

getReordering returns the reordering of lines from a visual index to a logical index for line breaks at the given offsets. Lines are concatenated from left to right. So for example, the fifth character from the left on the third line is getReordering(linebreaks)[linebreaks[1] + 4] (linebreaks[1] is the position after the last character of the second line, which is also the index of the first character on the third line, and adding four gets the fifth character from the left). The linebreaks array must include at least one value. The values must be in strictly increasing order (no duplicates) between 1 and the length of the text, inclusive. The last value must be the length of the text.

func (p *paragraph) getReordering(linebreaks []int) []int

getStrongTypeN0 method #

getStrongTypeN0 maps character's directional code to strong type as required by rule N0. TODO: have separate type for "strong" directionality.

func (p *bracketPairer) getStrongTypeN0(index int) Class

in method #

in returns if x is equal to any of the values in set.

func (c Class) in(set ...Class) bool

isRemovedByX9 function #

isRemovedByX9 reports whether the type is one of the types removed in X9.

func isRemovedByX9(c Class) bool

isWhitespace function #

isWhitespace reports whether the type is considered a whitespace type for the line break rules.

func isWhitespace(c Class) bool

isolatingRunSequence method #

Rule X10, second bullet: Determine the start-of-sequence (sos) and end-of-sequence (eos) types, either L or R, for each isolating run sequence.

func (p *paragraph) isolatingRunSequence(indexes []int) *isolatingRunSequence

lastDirectionalIsolateStatus method #

func (s *directionalStatusStack) lastDirectionalIsolateStatus() bool

lastDirectionalOverrideStatus method #

func (s *directionalStatusStack) lastDirectionalOverrideStatus() Class

lastEmbeddingLevel method #

func (s *directionalStatusStack) lastEmbeddingLevel() level

locateBrackets method #

locateBrackets locates matching bracket pairs according to BD16. This implementation uses a linked list instead of a stack, because, while elements are added at the front (like a push) they are not generally removed in atomic 'pop' operations, reducing the benefit of the stack archetype.

func (p *bracketPairer) locateBrackets(pairTypes []bracketType, pairValues []rune)

lookup method #

lookup returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookup(s []byte) (v uint8, sz int)

lookup method #

lookup returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookup(s []byte) (v uint8, sz int)

lookup method #

lookup returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookup(s []byte) (v uint8, sz int)

lookup method #

lookup returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookup(s []byte) (v uint8, sz int)

lookup method #

lookup returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookup(s []byte) (v uint8, sz int)

lookup method #

lookup returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookup(s []byte) (v uint8, sz int)

lookupString method #

lookupString returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookupString(s string) (v uint8, sz int)

lookupString method #

lookupString returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookupString(s string) (v uint8, sz int)

lookupString method #

lookupString returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookupString(s string) (v uint8, sz int)

lookupString method #

lookupString returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookupString(s string) (v uint8, sz int)

lookupString method #

lookupString returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookupString(s string) (v uint8, sz int)

lookupString method #

lookupString returns the trie value for the first UTF-8 encoding in s and the width in bytes of this encoding. The size will be 0 if s does not hold enough bytes to complete the encoding. len(s) must be greater than 0.

func (t *bidiTrie) lookupString(s string) (v uint8, sz int)

lookupStringUnsafe method #

lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupStringUnsafe(s string) uint8

lookupStringUnsafe method #

lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupStringUnsafe(s string) uint8

lookupStringUnsafe method #

lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupStringUnsafe(s string) uint8

lookupStringUnsafe method #

lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupStringUnsafe(s string) uint8

lookupStringUnsafe method #

lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupStringUnsafe(s string) uint8

lookupStringUnsafe method #

lookupStringUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupStringUnsafe(s string) uint8

lookupUnsafe method #

lookupUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupUnsafe(s []byte) uint8

lookupUnsafe method #

lookupUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupUnsafe(s []byte) uint8

lookupUnsafe method #

lookupUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupUnsafe(s []byte) uint8

lookupUnsafe method #

lookupUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupUnsafe(s []byte) uint8

lookupUnsafe method #

lookupUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupUnsafe(s []byte) uint8

lookupUnsafe method #

lookupUnsafe returns the trie value for the first UTF-8 encoding in s. s must start with a full and valid UTF-8 encoded rune.

func (t *bidiTrie) lookupUnsafe(s []byte) uint8

lookupValue method #

lookupValue determines the type of block n and looks up the value for b.

func (t *bidiTrie) lookupValue(n uint32, b byte) uint8

lookupValue method #

lookupValue determines the type of block n and looks up the value for b.

func (t *bidiTrie) lookupValue(n uint32, b byte) uint8

lookupValue method #

lookupValue determines the type of block n and looks up the value for b.

func (t *bidiTrie) lookupValue(n uint32, b byte) uint8

lookupValue method #

lookupValue determines the type of block n and looks up the value for b.

func (t *bidiTrie) lookupValue(n uint32, b byte) uint8

lookupValue method #

lookupValue determines the type of block n and looks up the value for b.

func (t *bidiTrie) lookupValue(n uint32, b byte) uint8

lookupValue method #

lookupValue determines the type of block n and looks up the value for b.

func (t *bidiTrie) lookupValue(n uint32, b byte) uint8

matchOpener method #

matchOpener reports whether characters at given positions form a matching bracket pair.

func (p *bracketPairer) matchOpener(pairValues []rune, opener int, closer int) bool

maxLevel function #

func maxLevel(a level, b level) level

newBidiTrie function #

func newBidiTrie(i int) *bidiTrie

newBidiTrie function #

func newBidiTrie(i int) *bidiTrie

newBidiTrie function #

func newBidiTrie(i int) *bidiTrie

newBidiTrie function #

func newBidiTrie(i int) *bidiTrie

newBidiTrie function #

func newBidiTrie(i int) *bidiTrie

newBidiTrie function #

func newBidiTrie(i int) *bidiTrie

newParagraph function #

newParagraph initializes a paragraph. The user needs to supply a few arrays corresponding to the preprocessed text input. The types correspond to the Unicode BiDi classes for each rune. pairTypes indicates the bracket type for each rune. pairValues provides a unique bracket class identifier for each rune (suggested is the rune of the open bracket for opening and matching close brackets, after normalization). The embedding levels are optional, but may be supplied to encode embedding levels of styled text.

func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) (*paragraph, error)

pop method #

func (s *directionalStatusStack) pop()

prepareInput method #

Initialize the p.pairTypes, p.pairValues and p.types from the input previously set by p.SetBytes() or p.SetString(). Also limit the input up to (and including) a paragraph separator (bidi class B). The function p.Order() needs these values to be set, so this preparation could be postponed. But since the SetBytes and SetStrings functions return the length of the input up to the paragraph separator, the whole input needs to be processed anyway and should not be done twice. The function has the same return values as SetBytes() / SetString()

func (p *Paragraph) prepareInput() (n int, err error)

push method #

func (s *directionalStatusStack) push(level level, overrideStatus Class, isolateStatus bool)

resolveBrackets method #

resolveBrackets implements rule N0 for a list of pairs.

func (p *bracketPairer) resolveBrackets(dirEmbed Class, initialTypes []Class)

resolveImplicitLevels method #

7) resolving implicit embedding levels Rules I1, I2.

func (s *isolatingRunSequence) resolveImplicitLevels()

resolveNeutralTypes method #

6) resolving neutral types Rules N1-N2.

func (s *isolatingRunSequence) resolveNeutralTypes()

resolvePairedBrackets function #

resolvePairedBrackets runs the paired bracket part of the UBA algorithm. For each rune, it takes the indexes into the original string, the class the bracket type (in pairTypes) and the bracket identifier (pairValues). It also takes the direction type for the start-of-sentence and the embedding level. The identifiers for bracket types are the rune of the canonicalized opening bracket for brackets (open or close) or 0 for runes that are not brackets.

func resolvePairedBrackets(s *isolatingRunSequence)

resolveWeakTypes method #

Resolving weak types Rules W1-W7. Note that some weak types (EN, AN) remain after this processing is complete.

func (s *isolatingRunSequence) resolveWeakTypes()

reverseBracket method #

TODO: find a better API and expose.

func (p Properties) reverseBracket(r rune) rune

run method #

The algorithm. Does not include line-based processing (Rules L1, L2). These are applied later in the line-based phase of the algorithm.

func (p *paragraph) run()

setBracketsToType method #

func (p *bracketPairer) setBracketsToType(loc bracketPair, dirPair Class, initialTypes []Class)

setLevels function #

func setLevels(levels []level, newLevel level)

setTypes function #

func setTypes(types []Class, newType Class)

typeForLevel function #

typeForLevel reports the strong type (L or R) corresponding to the level.

func typeForLevel(level level) Class

validateLineBreaks function #

func validateLineBreaks(linebreaks []int, textLength int) error

validateParagraphEmbeddingLevel function #

func validateParagraphEmbeddingLevel(embeddingLevel level) error

validatePbTypes function #

func validatePbTypes(pairTypes []bracketType) error

validatePbValues function #

func validatePbValues(pairValues []rune, pairTypes []bracketType) error

validateTypes function #

func validateTypes(types []Class) error

Generated with Arrow