~jaro/balkon

ref: 85a32d42819fa08632855b2106af255f2e52e3fa balkon/test/Data/Text/ParagraphLayout/Plain/ParagraphData.hs -rw-r--r-- 6.8 KiB
85a32d42Jaro Add centre/right paragraph alignment. 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{-# OPTIONS_GHC -fno-warn-deprecations #-}
module Data.Text.ParagraphLayout.Plain.ParagraphData
    ( arabicFillerParagraph
    , arabicHelloParagraph
    , czechHelloParagraph
    , devanagariAccentParagraph
    , devanagariParagraph
    , devanagariPrefixedAccentParagraph
    , emptyParagraph
    , emptySpanParagraph
    , hardBreaksLTRParagraph
    , hardBreaksRTLParagraph
    , ligatureParagraph
    , loremIpsumParagraph
    , manySpacesParagraph
    , mixedLanguageLTRParagraph
    , mixedScriptSerbianParagraph
    , mixedScriptWordsParagraph
    , spannedArabicFillerParagraph
    , spannedLoremIpsumParagraph
    , trivialParagraph
    )
where

import Data.Text.ParagraphLayout.Plain
    ( Paragraph
    , ParagraphOptions
    , SpanOptions (spanLanguage)
    , defaultSpanOptions
    )
import Data.Text.ParagraphLayout.ParagraphConstruction

-- | Span with text in the Arabic language.
ar :: String -> (SpanOptions, String)
ar = (,) defaultSpanOptions { spanLanguage = "ar" }

-- | Span with text in the Czech language.
cs :: String -> (SpanOptions, String)
cs = (,) defaultSpanOptions { spanLanguage = "cs" }

-- | Span with text in the English language.
en :: String -> (SpanOptions, String)
en = (,) defaultSpanOptions { spanLanguage = "en" }

-- | Span with text in the Japanese language.
ja :: String -> (SpanOptions, String)
ja = (,) defaultSpanOptions { spanLanguage = "ja" }

-- | Span with text in the Serbian language.
sr :: String -> (SpanOptions, String)
sr = (,) defaultSpanOptions { spanLanguage = "sr" }

-- | Span with text in no language.
zxx :: String -> (SpanOptions, String)
zxx = (,) defaultSpanOptions { spanLanguage = "zxx" }

emptyParagraph :: ParagraphOptions -> Paragraph ()
emptyParagraph = "x" |<>| "zzzzzzz"

emptySpanParagraph :: ParagraphOptions -> Paragraph ()
emptySpanParagraph = "xx" |< en "" >| "zzzzz"

trivialParagraph :: ParagraphOptions -> Paragraph ()
trivialParagraph = "xxx" |< en "a" >| "zzz"

ligatureParagraph :: ParagraphOptions -> Paragraph ()
ligatureParagraph = "" |< en "inefficient" >| ""

manySpacesParagraph :: ParagraphOptions -> Paragraph ()
manySpacesParagraph = "  " |< zxx " aaaaaa aaaaaa  aaaaaa   aaaaaa    " >| "  "

-- | Filler text using the Arabic script.
-- Source: <https://generator.lorem-ipsum.info/_arabic>
arabicFillerParagraph :: ParagraphOptions -> Paragraph ()
arabicFillerParagraph = "xxxx" |< zxx "إعلان بأيدي وبغطاء هذه من. عرض غينيا يتمكن واعتلاء في. و فرنسا الثانية وفي, أسر إذ السبب ارتكبها مليارات. فكان الشتاء، ما حتى, غير أن وصغار الأخذ. في الصفحة لهيمنة وتتحمّل وتم, أن أما وبداية الغالي." >| "z"

spannedArabicFillerParagraph :: ParagraphOptions -> Paragraph ()
spannedArabicFillerParagraph = "xxxx" |< zxx "إعلان بأيدي وبغطاء " >|< zxx "هذه من. عرض" >|< zxx " غينيا يتمكن واعتلاء " >|< zxx "في. و فرنسا" >|< zxx " الثانية وفي, أسر " >|< zxx "إذ السبب ارتكبها" >|< zxx " مليارات. فكان الشتاء، " >|< zxx "ما حتى, غير" >|< zxx " أن وصغار الأخذ. " >|< zxx "في الصفحة لهيمنة" >|< zxx " وتتحمّل وتم, أن " >|< zxx "أما وبداية الغالي." >| "z"

-- | Filler text using the Latin script.
-- Source: <https://www.lipsum.com/>
loremIpsumParagraph :: ParagraphOptions -> Paragraph ()
loremIpsumParagraph = "xxxx" |< zxx "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." >| "z"

spannedLoremIpsumParagraph :: ParagraphOptions -> Paragraph ()
spannedLoremIpsumParagraph = "xxxx" |< zxx "Lorem ipsum dolor " >|< zxx "sit amet, consectetur" >|< zxx " adipiscing elit, sed " >|< zxx "do eiusmod tempor" >|< zxx " incididunt ut labore " >|< zxx "et dolore magna" >|< zxx " aliqua. Ut enim " >|< zxx "ad minim veniam," >|< zxx " quis nostrud exercitation " >|< zxx "ullamco laboris nisi" >|< zxx " ut aliquip ex " >|< zxx "ea commodo consequat." >|< zxx " Duis aute irure " >|< zxx "dolor in reprehenderit" >|< zxx " in voluptate velit " >|< zxx "esse cillum dolore" >|< zxx " eu fugiat nulla " >|< zxx "pariatur. Excepteur" >|< zxx " sint occaecat cupidatat " >|< zxx "non proident, sunt" >|< zxx " in culpa qui " >|< zxx "officia deserunt mollit" >|< zxx " anim id est " >|< zxx "laborum." >| "z"

-- | Source:
-- <https://en.wikipedia.org/w/index.php?title=As-salamu_alaykum&oldid=1158575357>
arabicHelloParagraph :: ParagraphOptions -> Paragraph ()
arabicHelloParagraph = "xxxxx" |< ar "ٱلسَّلَامُ عَلَيْكُمَا!" >| "zz"

czechHelloParagraph :: ParagraphOptions -> Paragraph ()
czechHelloParagraph = "xxxxx" |< cs "Ahoj, světe!" >| "zz"

mixedScriptSerbianParagraph :: ParagraphOptions -> Paragraph ()
mixedScriptSerbianParagraph = "xxxxxx" |< sr "Vikipedija (Википедија)" >| "zzzz"

-- | For testing line breaking on boundaries that are different from script
-- boundaries.
mixedScriptWordsParagraph :: ParagraphOptions -> Paragraph ()
mixedScriptWordsParagraph = "xxxxxxx" |< zxx "jjjжжжjjj jjjжжжjjj жжжjjjжжж жжжjjjжжж jжj jжj жjж жjж" >| "zzzzzzzz"

mixedLanguageLTRParagraph :: ParagraphOptions -> Paragraph ()
mixedLanguageLTRParagraph = "Tak " |< cs "jsem tady, " >|< ja "世界!" >| "zzzzzz"

-- | Source: <https://faultlore.com/blah/text-hates-you/>
devanagariParagraph :: ParagraphOptions -> Paragraph ()
devanagariParagraph = "xxxxxxxx" |< zxx "पन्ह पन्ह त्र र्च कृकृ ड्ड न्हृे" >| "zzzzzzzz"

devanagariAccentParagraph :: ParagraphOptions -> Paragraph ()
devanagariAccentParagraph = "" |< zxx "\x954" >| ""

devanagariPrefixedAccentParagraph :: ParagraphOptions -> Paragraph ()
devanagariPrefixedAccentParagraph = "#" |< zxx "\x954" >| ""

-- | Test hard line breaks with Latin characters:
--
-- - after a short line (no soft line breaks needed),
-- - after a longer line (soft line breaks needed),
-- - after a long word (line break in the middle of a word needed),
-- - after spaces,
-- - after other line breaks.
hardBreaksLTRParagraph :: ParagraphOptions -> Paragraph ()
hardBreaksLTRParagraph = "x" |< zxx "jjjjjj\njjjjjj jjjjjj jjjjjj\nmmmmmm \njjjjjj\n\nmm mm mm" >| ""

-- | Test hard line breaks like `hardBreaksLTRParagraph`,
-- but with Arabic characters.
hardBreaksRTLParagraph :: ParagraphOptions -> Paragraph ()
hardBreaksRTLParagraph = "x" |< zxx "دددددد\nدددددد دددددد دددددد\nسسسسسسس \nدددددد\n\nسس سس سس" >| ""