Repository navigation
Redesign the command-line demo and move it into demo.py - #12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
python bidi.pynow lists the built-in examples instead of running all six with verbose output.--all,--example N, your own text (python bidi.py "Hello שלום"), and--file PATH.--brief(results only, no tables) and--direction {auto,ltr,rtl}.[LRI],[PDI],[RLM], …) or\uXXXXescapes. The built-in examples use tags too, and the output prints controls back as tags.bidi.pydoes not implement P1.demo.py;bidi.py's__main__just callsdemo.main(), sobidi.pyholds only the algorithm.Example fixes
Hello שלום (עולם), where N0 makes both parentheses R and L4 mirrors them.README.md and CLAUDE.md are updated to match.
Testing
bidi.py's algorithm code is unchanged.--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