Skip to content

Simplify the two P2 scans and read original_type in both - #22

Merged
isaranga merged 2 commits into
mainfrom
fsi-scan-strong-types
Nov 30, 2026
Merged

isaranga merged 2 commits into
mainfrom
fsi-scan-strong-types

Conversation

@isaranga

Copy link
Copy Markdown
Owner

Summary

Two small cleanups to the two P2 scans: the paragraph-level scan in determine_paragraph_embedding_level (P2) and the scan after an FSI in _resolve_fsi_direction (X5c applies P2 to the text after the FSI). Results and output are unchanged.

Changes

  • Check STRONG_TYPES once in the FSI scan. This is the same simplification Name the first strong character in the Phase P verbose trace #21 made to the paragraph scan. The loop tests STRONG_TYPES once and then returns LRI for L and RLI for R or AL. It used to test R/AL and L in two separate branches. The ('R', 'AL') literal no longer appears in bidi.py.
  • Read original_type in the paragraph scan. P2 looks at each character's Bidi_Class from the Unicode data. The scan read character_type, which holds that value only because no rule has run yet. It now reads original_type, as the FSI scan already did, so it no longer depends on when it is called. The verbose P2 line prints the same field.

No docs changes are needed, since the verbose output is the same.

Testing

  • python tests/run_bidi_tests.py: 91,707 passed, 0 failed
  • python tests/run_bidi_type_tests.py: 770,241 passed, 0 failed

🤖 Generated with Claude Code

isaranga and others added 2 commits November 30, 2026 15:09
Same simplification as the P2 scan in determine_paragraph_embedding_level:
_resolve_fsi_direction now tests STRONG_TYPES once and returns LRI for L,
RLI for R or AL, in place of two separate branches.

Co-Authored-By: Claude <noreply@anthropic.com>
P2 looks at each character's Bidi_Class from the Unicode data. The scan
in determine_paragraph_embedding_level read character_type, which only
holds that value because no rule has run yet. It now reads
original_type, like the same P2 scan in _resolve_fsi_direction (X5c),
so it no longer depends on when it is called. Results are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
@isaranga
isaranga merged commit bae9e5d into main Nov 30, 2026
6 checks passed
@isaranga
isaranga deleted the fsi-scan-strong-types branch November 30, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant