Browse Source

First and final commit

main
Joshua Moerman 2 years ago
commit
95f2449117
  1. 145
      Main.hs
  2. 11
      README.md
  3. 456
      Text Substitutions.plist

145
Main.hs

@ -0,0 +1,145 @@
{-# language OverloadedStrings #-}
import Data.Text hiding (concat)
import Data.Text.IO
import Prelude hiding (putStr)
flatten ls = [ (l, r) | (l, rs) <- ls, r <- rs ]
convLatex ls = [ (l, replace "\\" "«" r) | (l, r) <- ls ]
-- not used, doesn't work well in conjunction with lower
greekUpper = convLatex
[ ("Α", "\\Alpha")
, ("Β", "\\Beta")
, ("Γ", "\\Gamma")
, ("Δ", "\\Delta")
, ("Ε", "\\Epsilon")
, ("Ζ", "\\Zeta")
, ("Η", "\\Eta")
, ("Θ", "\\Theta")
, ("Ι", "\\Iota")
, ("Κ", "\\Kappa")
, ("Λ", "\\Lambda")
, ("Μ", "\\Mu")
, ("Ν", "\\Nu")
, ("Ξ", "\\Xi")
, ("Ο", "\\Omikron")
, ("Π", "\\Pi")
, ("Ρ", "\\Rho")
, ("Σ", "\\Sigma")
, ("Τ", "\\Tau")
, ("Υ", "\\Upsilon")
, ("Φ", "\\Phi")
, ("Χ", "\\Chi")
, ("Ψ", "\\Psi")
, ("Ω", "\\Omega")
]
greek = convLatex
[ ("α", "\\alpha")
, ("β", "\\beta")
, ("γ", "\\gamma")
, ("δ", "\\delta")
, ("ε", "\\epsilon")
, ("ζ", "\\zeta")
, ("η", "\\eta")
, ("θ", "\\theta")
, ("ι", "\\iota")
, ("κ", "\\kappa")
, ("λ", "\\lambda")
, ("μ", "\\mu")
, ("ν", "\\nu")
, ("ξ", "\\xi")
, ("ο", "\\omikron")
, ("π", "\\pi")
, ("ρ", "\\rho")
, ("σ", "\\sigma")
, ("τ", "\\tau")
, ("υ", "\\upsilon")
, ("φ", "\\phi")
, ("χ", "\\chi")
, ("ψ", "\\psi")
, ("ω", "\\omega")
]
logic = (convLatex . flatten)
[ ("", ["\\wedge", "\\and"])
, ("", ["\\vee", "\\vee"])
, ("¬", ["\\not", "\\neg"])
, ("", ["\\iff"])
, ("", ["\\implies"])
, ("", ["\\top"])
, ("", ["\\bottom", "\\perp"])
, ("", ["\\exists"])
, ("", ["\\forall"])
]
set = (convLatex . flatten)
[ ("", ["\\emptyset"])
, ("", ["\\union", "\\cup"])
, ("", ["\\intersection", "\\cap"])
, ("", ["\\neq"])
, ("", ["\\subset"])
, ("", ["\\subseteq"])
, ("", ["\\subsetneq"])
, ("", ["\\in"])
, ("", ["\\notin"])
]
others = convLatex
[ ("", "\\iso")
, ("~", "\\sim")
, ("", "\\leq")
, ("", "\\geq")
, ("", "\\infty")
, ("", "\\to")
, ("", "\\mapsto")
, ("", "\\epi")
, ("", "\\mono")
, ("", "\\circ")
, ("·", "\\cdot")
, ("×", "\\times")
, ("", "\\sum")
, ("", "\\prod")
, ("", "\\coprod")
, ("", "\\oplus")
, ("", "\\otimes")
]
mathbb = (convLatex . flatten)
[ ("𝔸", ["\\atoms", "\\AA"])
, ("", ["\\naturals", "\\NN"])
, ("", ["\\rationals", "\\QQ"])
, ("", ["\\reals", "\\RR"])
, ("", ["\\integers", "\\ZZ"])
]
allReplacements :: [(Text, Text)]
allReplacements = concat [greek, logic, set, others, mathbb]
header =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
\<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n\
\<plist version=\"1.0\">\n\
\<array>\n\
\"
footer =
"</array>\n\
\</plist>\n\
\"
dict l r =
"\t<dict>\n\
\\t\t<key>phrase</key>\n\
\\t\t<string>" <> l <> "</string>\n\
\\t\t<key>shortcut</key>\n\
\\t\t<string>" <> r <> "</string>\n\
\\t</dict>\n\
\"
main = do
let allReplacements = (concat [greek, logic, set, others, mathbb]) :: [(Text, Text)]
putStr header
mapM (putStr . uncurry dict) allReplacements
putStr footer

11
README.md

@ -0,0 +1,11 @@
Replacements
============
For Mac OS. Run the following command:
```
runhaskell Main.hs > "Text Substitutions.plist"
```
Then drag & drop the file into the keyboard settings.

456
Text Substitutions.plist

@ -0,0 +1,456 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>phrase</key>
<string>α</string>
<key>shortcut</key>
<string>«alpha</string>
</dict>
<dict>
<key>phrase</key>
<string>β</string>
<key>shortcut</key>
<string>«beta</string>
</dict>
<dict>
<key>phrase</key>
<string>γ</string>
<key>shortcut</key>
<string>«gamma</string>
</dict>
<dict>
<key>phrase</key>
<string>δ</string>
<key>shortcut</key>
<string>«delta</string>
</dict>
<dict>
<key>phrase</key>
<string>ε</string>
<key>shortcut</key>
<string>«epsilon</string>
</dict>
<dict>
<key>phrase</key>
<string>ζ</string>
<key>shortcut</key>
<string>«zeta</string>
</dict>
<dict>
<key>phrase</key>
<string>η</string>
<key>shortcut</key>
<string>«eta</string>
</dict>
<dict>
<key>phrase</key>
<string>θ</string>
<key>shortcut</key>
<string>«theta</string>
</dict>
<dict>
<key>phrase</key>
<string>ι</string>
<key>shortcut</key>
<string>«iota</string>
</dict>
<dict>
<key>phrase</key>
<string>κ</string>
<key>shortcut</key>
<string>«kappa</string>
</dict>
<dict>
<key>phrase</key>
<string>λ</string>
<key>shortcut</key>
<string>«lambda</string>
</dict>
<dict>
<key>phrase</key>
<string>μ</string>
<key>shortcut</key>
<string>«mu</string>
</dict>
<dict>
<key>phrase</key>
<string>ν</string>
<key>shortcut</key>
<string>«nu</string>
</dict>
<dict>
<key>phrase</key>
<string>ξ</string>
<key>shortcut</key>
<string>«xi</string>
</dict>
<dict>
<key>phrase</key>
<string>ο</string>
<key>shortcut</key>
<string>«omikron</string>
</dict>
<dict>
<key>phrase</key>
<string>π</string>
<key>shortcut</key>
<string>«pi</string>
</dict>
<dict>
<key>phrase</key>
<string>ρ</string>
<key>shortcut</key>
<string>«rho</string>
</dict>
<dict>
<key>phrase</key>
<string>σ</string>
<key>shortcut</key>
<string>«sigma</string>
</dict>
<dict>
<key>phrase</key>
<string>τ</string>
<key>shortcut</key>
<string>«tau</string>
</dict>
<dict>
<key>phrase</key>
<string>υ</string>
<key>shortcut</key>
<string>«upsilon</string>
</dict>
<dict>
<key>phrase</key>
<string>φ</string>
<key>shortcut</key>
<string>«phi</string>
</dict>
<dict>
<key>phrase</key>
<string>χ</string>
<key>shortcut</key>
<string>«chi</string>
</dict>
<dict>
<key>phrase</key>
<string>ψ</string>
<key>shortcut</key>
<string>«psi</string>
</dict>
<dict>
<key>phrase</key>
<string>ω</string>
<key>shortcut</key>
<string>«omega</string>
</dict>
<dict>
<key>phrase</key>
<string>∧</string>
<key>shortcut</key>
<string>«wedge</string>
</dict>
<dict>
<key>phrase</key>
<string>∧</string>
<key>shortcut</key>
<string>«and</string>
</dict>
<dict>
<key>phrase</key>
<string>∨</string>
<key>shortcut</key>
<string>«vee</string>
</dict>
<dict>
<key>phrase</key>
<string>∨</string>
<key>shortcut</key>
<string>«vee</string>
</dict>
<dict>
<key>phrase</key>
<string>¬</string>
<key>shortcut</key>
<string>«not</string>
</dict>
<dict>
<key>phrase</key>
<string>¬</string>
<key>shortcut</key>
<string>«neg</string>
</dict>
<dict>
<key>phrase</key>
<string>⇔</string>
<key>shortcut</key>
<string>«iff</string>
</dict>
<dict>
<key>phrase</key>
<string>⇒</string>
<key>shortcut</key>
<string>«implies</string>
</dict>
<dict>
<key>phrase</key>
<string>⊤</string>
<key>shortcut</key>
<string>«top</string>
</dict>
<dict>
<key>phrase</key>
<string>⊥</string>
<key>shortcut</key>
<string>«bottom</string>
</dict>
<dict>
<key>phrase</key>
<string>⊥</string>
<key>shortcut</key>
<string>«perp</string>
</dict>
<dict>
<key>phrase</key>
<string>∃</string>
<key>shortcut</key>
<string>«exists</string>
</dict>
<dict>
<key>phrase</key>
<string>∀</string>
<key>shortcut</key>
<string>«forall</string>
</dict>
<dict>
<key>phrase</key>
<string>∅</string>
<key>shortcut</key>
<string>«emptyset</string>
</dict>
<dict>
<key>phrase</key>
<string>∪</string>
<key>shortcut</key>
<string>«union</string>
</dict>
<dict>
<key>phrase</key>
<string>∪</string>
<key>shortcut</key>
<string>«cup</string>
</dict>
<dict>
<key>phrase</key>
<string>∩</string>
<key>shortcut</key>
<string>«intersection</string>
</dict>
<dict>
<key>phrase</key>
<string>∩</string>
<key>shortcut</key>
<string>«cap</string>
</dict>
<dict>
<key>phrase</key>
<string>≠</string>
<key>shortcut</key>
<string>«neq</string>
</dict>
<dict>
<key>phrase</key>
<string>⊂</string>
<key>shortcut</key>
<string>«subset</string>
</dict>
<dict>
<key>phrase</key>
<string>⊆</string>
<key>shortcut</key>
<string>«subseteq</string>
</dict>
<dict>
<key>phrase</key>
<string>⊊</string>
<key>shortcut</key>
<string>«subsetneq</string>
</dict>
<dict>
<key>phrase</key>
<string>∊</string>
<key>shortcut</key>
<string>«in</string>
</dict>
<dict>
<key>phrase</key>
<string>∉</string>
<key>shortcut</key>
<string>«notin</string>
</dict>
<dict>
<key>phrase</key>
<string>≈</string>
<key>shortcut</key>
<string>«iso</string>
</dict>
<dict>
<key>phrase</key>
<string>~</string>
<key>shortcut</key>
<string>«sim</string>
</dict>
<dict>
<key>phrase</key>
<string>≤</string>
<key>shortcut</key>
<string>«leq</string>
</dict>
<dict>
<key>phrase</key>
<string>≥</string>
<key>shortcut</key>
<string>«geq</string>
</dict>
<dict>
<key>phrase</key>
<string>∞</string>
<key>shortcut</key>
<string>«infty</string>
</dict>
<dict>
<key>phrase</key>
<string>→</string>
<key>shortcut</key>
<string>«to</string>
</dict>
<dict>
<key>phrase</key>
<string>↦</string>
<key>shortcut</key>
<string>«mapsto</string>
</dict>
<dict>
<key>phrase</key>
<string>↠</string>
<key>shortcut</key>
<string>«epi</string>
</dict>
<dict>
<key>phrase</key>
<string>↪</string>
<key>shortcut</key>
<string>«mono</string>
</dict>
<dict>
<key>phrase</key>
<string>∘</string>
<key>shortcut</key>
<string>«circ</string>
</dict>
<dict>
<key>phrase</key>
<string>·</string>
<key>shortcut</key>
<string>«cdot</string>
</dict>
<dict>
<key>phrase</key>
<string>×</string>
<key>shortcut</key>
<string>«times</string>
</dict>
<dict>
<key>phrase</key>
<string>∑</string>
<key>shortcut</key>
<string>«sum</string>
</dict>
<dict>
<key>phrase</key>
<string>∏</string>
<key>shortcut</key>
<string>«prod</string>
</dict>
<dict>
<key>phrase</key>
<string>∐</string>
<key>shortcut</key>
<string>«coprod</string>
</dict>
<dict>
<key>phrase</key>
<string>⊕</string>
<key>shortcut</key>
<string>«oplus</string>
</dict>
<dict>
<key>phrase</key>
<string>⊗</string>
<key>shortcut</key>
<string>«otimes</string>
</dict>
<dict>
<key>phrase</key>
<string>𝔸</string>
<key>shortcut</key>
<string>«atoms</string>
</dict>
<dict>
<key>phrase</key>
<string>𝔸</string>
<key>shortcut</key>
<string>«AA</string>
</dict>
<dict>
<key>phrase</key>
<string>ℕ</string>
<key>shortcut</key>
<string>«naturals</string>
</dict>
<dict>
<key>phrase</key>
<string>ℕ</string>
<key>shortcut</key>
<string>«NN</string>
</dict>
<dict>
<key>phrase</key>
<string>ℚ</string>
<key>shortcut</key>
<string>«rationals</string>
</dict>
<dict>
<key>phrase</key>
<string>ℚ</string>
<key>shortcut</key>
<string>«QQ</string>
</dict>
<dict>
<key>phrase</key>
<string>ℝ</string>
<key>shortcut</key>
<string>«reals</string>
</dict>
<dict>
<key>phrase</key>
<string>ℝ</string>
<key>shortcut</key>
<string>«RR</string>
</dict>
<dict>
<key>phrase</key>
<string>ℤ</string>
<key>shortcut</key>
<string>«integers</string>
</dict>
<dict>
<key>phrase</key>
<string>ℤ</string>
<key>shortcut</key>
<string>«ZZ</string>
</dict>
</array>
</plist>
Loading…
Cancel
Save