module Hakyll.Shortcode (
ShortcodeService(..),
expandShortcodes,
applyShortcodes,
allServices
) where
import Hakyll.Shortcode.Service.GeoGebra
import Hakyll.Shortcode.Service.Gravatar
import Hakyll.Shortcode.Service.YouTube
import Hakyll.Shortcode.Service.Example
data ShortcodeService
= GeoGebra
| Gravatar
| YouTube
| Example
deriving Eq
expandShortcodesFor :: ShortcodeService -> String -> String
expandShortcodesFor x = case x of
GeoGebra -> expandGeoGebraShortcodes
Gravatar -> expandGravatarShortcodes
YouTube -> expandYouTubeShortcodes
Example -> expandExampleShortcodes
expandShortcodes :: [ShortcodeService] -> String -> String
expandShortcodes = foldr1 (.) . map expandShortcodesFor
applyShortcodes :: (Monad m, Functor f)
=> [ShortcodeService] -> f String -> m (f String)
applyShortcodes svc text =
return $ (fmap $ expandShortcodes svc) text
allServices :: [ShortcodeService]
allServices =
[ GeoGebra
, Gravatar
, YouTube
]