From 9e9581e91bb8392382ded2b573f4ab8256121ac4 Mon Sep 17 00:00:00 2001 From: isgav <51133755+isaranga@users.noreply.github.com> Date: Wed, 25 Nov 2026 11:38:12 +0200 Subject: [PATCH] Add demo examples that cover the weak rules W1-W5 and W7 Before this change, no built-in example made W1, W2, W3, W4, W5 or W7 change anything. Two new examples follow Example 3: Arabic text with a number (W2, W3, W4) and prices and percentages (W4, W5, W7). Example 2 now spells shalom with nikkud, so W1 turns the vowel points into R. Every weak rule now changes something in at least one example. The examples that were 4-7 are now 6-9. README.md and CLAUDE.md are updated to match. Co-Authored-By: Claude --- CLAUDE.md | 2 +- README.md | 2 +- demo.py | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index e976989..bd13615 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 diff --git a/README.md b/README.md index f3a7be0..efa390e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/demo.py b/demo.py index d8b0894..c4b3fa3 100644 --- a/demo.py +++ b/demo.py @@ -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",