Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ python tests/run_bidi_type_tests.py [--max-failures N] [--lines START-END] [--fa

**Run the demo** (`demo.py`, reached through `bidi.py`):
```bash
python bidi.py # list the seven built-in examples and usage hints
python bidi.py # list the nine built-in examples and usage hints
python bidi.py --all # run every example with verbose output
python bidi.py --example N # run one example
python bidi.py "text" # run your own text
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cd UnicodeBidiAlgorithm
python bidi.py
```

This lists the built-in examples (pure LTR, pure RTL, mixed text with digits, explicit embeddings, isolates, brackets, and two paragraphs) and shows how to run them:
This lists the built-in examples (pure LTR, pure RTL, mixed text with digits, Arabic text with a number, prices and percentages, explicit embeddings, isolates, brackets, and two paragraphs) and shows how to run them:

```bash
python bidi.py --example 3 # run one example, printing a table for every rule
Expand Down
20 changes: 17 additions & 3 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,29 @@
"Everything stays at level 0, so L2 leaves the order unchanged.",
),
(
"שלום",
"Pure RTL (Hebrew: shalom)",
"P2 finds R first, so the paragraph is RTL (level 1); L2 reverses the whole string.",
"שָׁלוֹם",
"Pure RTL (Hebrew with nikkud)",
"P2 finds R first, so the paragraph is RTL (level 1); W1 gives each vowel point (NSM) "
"the type of the letter before it (R); L2 reverses the whole string, so each point "
"now comes before its letter (rule L3 leaves fixing that to the renderer).",
),
(
"שלום 123 Hi",
"Mixed RTL + digits + LTR",
"N1 turns the space before the digits into R; I2 raises the digits and Latin letters to level 2.",
),
(
"سعر 1,000 ريال",
"Arabic text with a number",
"W2 turns the digits into AN because the last strong type before them is AL; "
"W3 then turns AL into R, and W4 makes the comma AN because it sits between two AN.",
),
(
"Price: $100, 1.5%",
"Prices and percentages",
"W4 makes the dot in 1.5 EN; W5 makes $ and % EN because they touch a number; "
"W6 makes the other separators ON; W7 turns every EN into L because the last strong type before it is L.",
),
(
"[LRE]Hello שלום[PDF]",
"LRE/PDF explicit embedding",
Expand Down
Loading