/usr/share/gitit-0.10.0.1/plugins/PigLatin.hs is in gitit 0.10.0.1-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | module PigLatin (plugin) where
-- This plugin converts a page to pig latin if the 'language' metadata
-- field is set to 'pig latin'. This demonstrates how to get access to
-- metadata in a plugin.
import Network.Gitit.Interface
import Data.Char (toLower, toUpper, isLower, isUpper, isLetter)
plugin :: Plugin
plugin = PageTransform $ \doc -> do
meta <- askMeta
case lookup "language" meta of
Just s | map toLower s == "pig latin" ->
return $ processWith pigLatinStr doc
_ -> return doc
pigLatinStr :: Inline -> Inline
pigLatinStr (Str "") = Str ""
pigLatinStr (Str (c:cs)) | isLower c && isConsonant c =
Str (cs ++ (c : "ay"))
pigLatinStr (Str (c:cs)) | isUpper c && isConsonant c =
Str (capitalize cs ++ (toLower c : "ay"))
pigLatinStr (Str x@(c:_)) | isLetter c = Str (x ++ "yay")
pigLatinStr x = x
isConsonant :: Char -> Bool
isConsonant c = c `notElem` "aeiouAEIOU"
capitalize :: String -> String
capitalize "" = ""
capitalize (c:cs) = toUpper c : cs
|