diff --git a/bidi.py b/bidi.py index 34487bb..6b41bfa 100644 --- a/bidi.py +++ b/bidi.py @@ -120,7 +120,7 @@ def determine_paragraph_embedding_level(chars: list[CharacterInfo], verbose: boo first_strong_char = None # the character found by P2, if any for ci in chars: - char_type = ci.character_type + char_type = ci.original_type if char_type in ISOLATE_INITIATOR_TYPES: open_isolate_count += 1 elif char_type == 'PDI': @@ -145,7 +145,7 @@ def determine_paragraph_embedding_level(chars: list[CharacterInfo], verbose: boo print(f"--- Rule P2 --- first strong character outside isolates: " f"index {first_strong_char.index} " f"(U+{ord(first_strong_char.character):04X} {shown_char}, " - f"type {first_strong_char.character_type}) " + f"type {first_strong_char.original_type}) " f"-> level {paragraph_level}") else: print(f"--- Rule P3 --- no strong character outside isolates " @@ -188,10 +188,11 @@ def _resolve_fsi_direction(chars: list[CharacterInfo], fsi_index: int) -> str: if depth == 0: break elif depth == 1: - if t in ('R', 'AL'): - return 'RLI' - elif t == 'L': - return 'LRI' + if t in STRONG_TYPES: + if t == 'L': + return 'LRI' + else: # R or AL + return 'RLI' return 'LRI' # default