Browse Source

Add smallcaps style.

Nicolas Lenz 1 month ago
parent
commit
650589a4a7
2 changed files with 32 additions and 1 deletions
  1. 31
    1
      src/Mock.hs
  2. 1
    0
      src/Mock/Help.hs

+ 31
- 1
src/Mock.hs View File

@@ -1,4 +1,4 @@
1
-{-# LANGUAGE OverloadedStrings #-}
1
+{-# LANGUAGE OverloadedStrings, LambdaCase #-}
2 2
 
3 3
 module Mock (styles, mockAlternate, mockRandom, letterspace, toDouble) where
4 4
 
@@ -24,6 +24,7 @@ styles = [
24 24
     ("lower", T.toLower),
25 25
     ("double", T.map toDouble),
26 26
     ("dedouble", T.map fromDouble),
27
+    ("smallcaps", T.map toSmallCap),
27 28
     ("cc", mockCC),
28 29
     ("b", mockB),
29 30
     ("square", mockSquare)]
@@ -77,6 +78,35 @@ fromDouble c = case ord c of
77 78
         | 120146 <= code && code <= 120171 -> chr $ code - 120146 + 97
78 79
     code -> chr code
79 80
 
81
+toSmallCap :: Char -> Char
82
+toSmallCap = \case
83
+    'a' -> chr 7424
84
+    'b' -> chr 665
85
+    'c' -> chr 7428
86
+    'd' -> chr 7429
87
+    'e' -> chr 7431
88
+    'f' -> chr 42800
89
+    'g' -> chr 610
90
+    'h' -> chr 668
91
+    'i' -> chr 618
92
+    'j' -> chr 7434
93
+    'k' -> chr 7435
94
+    'l' -> chr 671
95
+    'm' -> chr 7437
96
+    'n' -> chr 628
97
+    'o' -> chr 7439
98
+    'p' -> chr 7448
99
+    'q' -> chr 491
100
+    'r' -> chr 640
101
+    's' -> chr 42801
102
+    't' -> chr 7451
103
+    'u' -> chr 7452
104
+    'v' -> chr 7456
105
+    'w' -> chr 7457
106
+    'y' -> chr 655
107
+    'z' -> chr 7458
108
+    c -> c
109
+
80 110
 -- |Replaces all occurences of lowercase "ck" and "k" in a string with "cc"s.
81 111
 mockCC :: T.Text -> T.Text
82 112
 mockCC = T.replace "k" "cc" . T.replace "ck" "cc"

+ 1
- 0
src/Mock/Help.hs View File

@@ -17,6 +17,7 @@ styleHelp styleName = case styleName of
17 17
     "lower" -> "Turns all characters into lowercase ones."
18 18
     "double" -> "Turns characters (latin letters and numbers) into their double-struck variants (𝕖𝕩𝕒𝕞𝕡𝕝𝕖). Also known as blackboard bold."
19 19
     "dedouble" -> "Turns double-struck characters (like from the \"double\" style) back into normal ones."
20
+    "smallcaps" -> "Turns lowercase letters into small capitals."
20 21
     "cc" -> "Replaces all occurences of lowercase \"c\", \"ck\" and \"k\" with \"cc\"."
21 22
     "b" -> "Replaces all occurences of Bs (lower- and uppercase) with B-button emojis (🅱)."
22 23
     "square" -> "Shows the input spaced in the first line and the tail of the input lined afterwards."

Loading…
Cancel
Save