Bidi::BidiInfo
Inherits Bidi::BidiInfoCommon < Struct < Value < Object
Main structure for bidirectional analysis of UTF-8 text
Contains the results of bidi analysis for potentially multiple paragraphs. This is the primary entry point for analyzing mixed-direction text.
Properties:
text: The original input textoriginal_classes: BidiClass for each byte in the textlevels: Embedding level for each byte in the text (after resolution)paragraphs: Information about each paragraph in the text
This matches the Rust BidiInfo<'text> struct.
Constructors
Creates a new BidiInfo by analyzing text with the default data source
Parameters:
text: The UTF-8 text to analyzedefault_para_level: Optional base paragraph level (nil for auto-detection)
Returns: BidiInfo with analysis results
Creates a new BidiInfo with a custom data source for bidi data
This is the lower-level constructor that allows customizing the
Unicode data source. Most users should use BidiInfo.new() instead.
Parameters:
data_source: CustomBidiDataSourcefor bidi class lookupstext: The UTF-8 text to analyzedefault_para_level: Optional base paragraph level
Returns: BidiInfo with analysis results
Class methods
Instance methods
Reorders a line of text for visual display
Applies the Unicode Bidirectional Algorithm to reorder text within a line for proper visual display. This is the main method for getting text in the correct order for rendering.
Parameters:
para: The paragraph containing the lineline: Byte range within the text representing the line
Returns: The reordered text as a String
Note: Uses byte_slice for correct UTF-8 handling with multi-byte characters.
Finds visual runs within a line
Returns level runs in visual order as required by the Unicode Bidi Algorithm. The first return value is levels after applying L1-L2 rules. The second return value is runs (contiguous same-level ranges) in visual order.
Parameters:
para: The paragraph containing the lineline: Byte range within the text
Returns: Tuple of (Array(Level), Array(Range(Int32, Int32)))