Skip to content

Name the first strong character in the Phase P verbose trace - #21

Merged
isaranga merged 2 commits into
mainfrom
p2-trace-first-strong-char
Nov 30, 2026
Merged

isaranga merged 2 commits into
mainfrom
p2-trace-first-strong-char

Conversation

@isaranga

@isaranga isaranga commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

With verbose=True, Phase P passed the same list as both Before and After to print_table. Because print_table prints "(no changes)" without a table when the two match, the P2/P3 trace never showed anything useful. In particular, it never said which character set the paragraph level.

Phase P now prints one line after its header:

=== Phase P: Paragraph Embedding Level = 1 ===
--- Rule P2 --- first strong character outside isolates: index 0 (U+05E9 ש‎, type R) -> level 1

When no strong character is found outside isolates, it prints this instead:

--- Rule P3 --- no strong character outside isolates -> default level 0

The algorithm is unchanged; only the verbose output differs.

Changes

  • bidi.py: determine_paragraph_embedding_level remembers the first strong character it finds and prints the P2 or P3 line. The comment that described a table that was never shown is replaced.
  • bidi.py: the P2 scan now checks STRONG_TYPES once and then picks the level from the type (0 for L, 1 for R or AL). It used to test R/AL and L in two separate branches that did the same work. The result is the same.
  • README.md: describes the Phase P line and adds it to the tracing example, copied from real output.
  • CLAUDE.md: describes the Phase P line, and no longer mentions a P table.

Testing

  • python tests/run_bidi_tests.py: 91,707 passed, 0 failed
  • python tests/run_bidi_type_tests.py: 770,241 passed, 0 failed
  • Checked the verbose output by hand for both the P2 and the P3 case.

🤖 Generated with Claude Code

isaranga and others added 2 commits November 30, 2026 11:46
The P2/P3 trace passed identical Before/After rows to print_table, so it
only ever printed "(no changes)". It now prints one line naming the
character that set the paragraph level (P2), or saying that none was
found and the default level applies (P3). README.md and CLAUDE.md
describe the new line.

Co-Authored-By: Claude <noreply@anthropic.com>
The scan tested R/AL and L in two branches that both stored the
character and stopped. It now tests STRONG_TYPES once and chooses the
level from the type: 0 for L, 1 for R or AL.

Co-Authored-By: Claude <noreply@anthropic.com>
@isaranga
isaranga merged commit df5f6b7 into main Nov 30, 2026
6 checks passed
@isaranga
isaranga deleted the p2-trace-first-strong-char branch November 30, 2026 10:18
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