@@ 78,6 78,35 @@ spec = do
, runScript = Just "Cyrl"
}
]
+ it "handles Arabic text with English inside" $ do
+ let inputSpan = sampleSpan arabicAroundEnglish
+ let runs = spanToRuns inputSpan
+ runs `shouldBe`
+ [ Run
+ { runOffsetInSpan = 0
+ , runText = pack "في "
+ , runDirection = Just DirRTL
+ , runScript = Just "Arab"
+ }
+ , Run
+ { runOffsetInSpan = 5
+ , runText = pack "XHTML 1.0 "
+ , runDirection = Just DirLTR
+ , runScript = Just "Latn"
+ }
+ , Run
+ { runOffsetInSpan = 15
+ , runText = pack "يتم تحقيق ذلك بإضافة العنصر المضمن "
+ , runDirection = Just DirRTL
+ , runScript = Just "Arab"
+ }
+ , Run
+ { runOffsetInSpan = 79
+ , runText = pack "bdo."
+ , runDirection = Just DirLTR
+ , runScript = Just "Latn"
+ }
+ ]
it "handles English text with Arabic inside" $ do
let inputSpan = sampleSpan englishAroundArabic
let runs = spanToRuns inputSpan
@@ 1,8 1,11 @@
module Data.Text.ParagraphLayout.TextData
- ( englishEmpty
- , czechHello
+ ( arabicEmpty
+ , englishEmpty
+ , englishWord
, arabicHello
+ , czechHello
, serbianMixedScript
+ , arabicAroundEnglish
, englishAroundArabic
)
where
@@ 13,6 16,13 @@ import Data.Text.Glyphize (Direction (DirLTR, DirRTL))
type Language = String
type Sample = (Direction, Language, Text)
+arabicEmpty :: Sample
+arabicEmpty =
+ ( DirRTL
+ , "ar"
+ , empty
+ )
+
englishEmpty :: Sample
englishEmpty =
( DirLTR
@@ 20,11 30,11 @@ englishEmpty =
, empty
)
-czechHello :: Sample
-czechHello =
- ( DirLTR
- , "cs"
- , pack "Ahoj, světe!"
+englishWord :: Sample
+englishWord =
+ ( DirRTL
+ , "en"
+ , pack "word"
)
arabicHello :: Sample
@@ 34,6 44,13 @@ arabicHello =
, pack "سلام"
)
+czechHello :: Sample
+czechHello =
+ ( DirLTR
+ , "cs"
+ , pack "Ahoj, světe!"
+ )
+
serbianMixedScript :: Sample
serbianMixedScript =
( DirLTR
@@ 43,6 60,15 @@ serbianMixedScript =
-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
+arabicAroundEnglish :: Sample
+arabicAroundEnglish =
+ ( DirRTL
+ , "ar"
+ , pack "في XHTML 1.0 يتم تحقيق ذلك بإضافة العنصر المضمن bdo."
+ )
+
+-- | Source:
+-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
englishAroundArabic :: Sample
englishAroundArabic =
( DirLTR