Skip to content

Redesign the command-line demo and move it into demo.py - #12

Merged
isaranga merged 2 commits into
mainfrom
redesign-demo
Nov 23, 2026
Merged

isaranga merged 2 commits into
mainfrom
redesign-demo

Conversation

@isaranga

Copy link
Copy Markdown
Owner

Summary

  • python bidi.py now lists the built-in examples instead of running all six with verbose output.
  • New modes: --all, --example N, your own text (python bidi.py "Hello שלום"), and --file PATH.
  • Every mode accepts --brief (results only, no tables) and --direction {auto,ltr,rtl}.
  • Bidi controls can be written as tags ([LRI], [PDI], [RLM], …) or \uXXXX escapes. The built-in examples use tags too, and the output prints controls back as tags.
  • Text with several paragraphs is split and run one paragraph at a time, since bidi.py does not implement P1.
  • Each example has a "Watch for" note pointing at the rule it shows.
  • Output is forced to UTF-8, so Hebrew prints in Windows consoles.
  • The demo lives in the new demo.py; bidi.py's __main__ just calls demo.main(), so bidi.py holds only the algorithm.

Example fixes

  • The isolate example was labelled "LRI/FSI" but only uses LRI → now "LRI/PDI isolate".
  • The "N0" example used curly quotes, which aren't bracket pairs, so N0 never fired. It's replaced with Hello שלום (עולם), where N0 makes both parentheses R and L4 mirrors them.

README.md and CLAUDE.md are updated to match.

Testing

  • Both conformance suites pass: BidiCharacterTest 91,707/91,707, BidiTest 770,241/770,241. bidi.py's algorithm code is unchanged.
  • Tried every mode in PowerShell with no encoding setup: listing, --all, --example (valid and out of range), user text with tags and escapes, --direction rtl, a two-paragraph CRLF file, and a missing file.

🤖 Generated with Claude Code

isaranga and others added 2 commits November 23, 2026 16:12
python bidi.py now lists the built-in examples instead of running them
all. New modes: --all, --example N, your own text, and --file PATH, each
accepting --brief and --direction {auto,ltr,rtl}. User text may name bidi
controls with [LRI]-style tags or \uXXXX escapes, and is split into
paragraphs before running (P1 is not implemented in bidi.py).

Each example now has a "Watch for" note. Fix two mislabelled examples:
the isolate example uses LRI/PDI (not FSI), and the bracket example is
replaced with one where N0 and L4 actually apply.

Co-Authored-By: Claude <noreply@anthropic.com>
The examples now use [LRE], [PDF], [LRI], [PDI] and [RLM] instead of
\u escapes, and are expanded with expand_escapes_and_tags before they
run, just like user text. The Input and Reordered text lines print
control characters back as tags (show_controls_as_tags), so they can be
read and copied onto the command line.

Co-Authored-By: Claude <noreply@anthropic.com>
@isaranga
isaranga merged commit fdf175f into main Nov 23, 2026
6 checks passed
@isaranga
isaranga deleted the redesign-demo branch November 23, 2026 14:50
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