packages feed

balkon-1.1.0.0: test/Data/Text/ParagraphLayout/TextData.hs

module Data.Text.ParagraphLayout.TextData
    ( arabicEmpty
    , englishEmpty
    , englishWord
    , arabicHello
    , czechHello
    , serbianMixedScript
    , mixedDirectionNumbers
    , mixedDirectionSimple
    , arabicAroundEnglish
    , englishAroundArabic
    )
where

import Data.Text (Text, empty, pack)
import Data.Text.Glyphize (Direction (DirLTR, DirRTL))

type Language = String
type DirectionRunLengths = [Int]
type Sample = (Direction, Language, Text, DirectionRunLengths)

arabicEmpty :: Sample
arabicEmpty =
    ( DirRTL
    , "ar"
    , empty
    , []
    )

englishEmpty :: Sample
englishEmpty =
    ( DirLTR
    , "en"
    , empty
    , []
    )

englishWord :: Sample
englishWord =
    ( DirRTL
    , "en"
    , pack "word"
    , [4]
    )

arabicHello :: Sample
arabicHello =
    ( DirRTL
    , "ar"
    , pack "سلام"
    , [4]
    )

czechHello :: Sample
czechHello =
    ( DirLTR
    , "cs"
    , pack "Ahoj, světe!"
    , [12]
    )

serbianMixedScript :: Sample
serbianMixedScript =
    ( DirLTR
    , "sr"
    , pack "Vikipedija (Википедија)"
    , [23]
    )

-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
mixedDirectionNumbers :: Sample
mixedDirectionNumbers =
    ( DirLTR
    , "mul"
    , pack "one two ثلاثة 1234 خمسة"
    , [8, 6, 4, 5]
    )

-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
--
-- Used to test the effect of base direction.
mixedDirectionSimple :: Direction -> Sample
mixedDirectionSimple dir =
    ( dir
    , "ar"
    , pack "bahrainمصرkuwait"
    , [7, 3, 6]
    )

-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
arabicAroundEnglish :: Sample
arabicAroundEnglish =
    ( DirRTL
    , "ar"
    , pack "في XHTML 1.0 يتم تحقيق ذلك بإضافة العنصر المضمن bdo."
    , [3, 9, 36, 3, 1]
    )

-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
englishAroundArabic :: Sample
englishAroundArabic =
    ( DirLTR
    , "en"
    , pack "The title is مفتاح معايير الويب in Arabic."
    , [13, 18, 11]
    )